home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: Tape Archive
(archive/tar).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| Tape Archive (archive/tar)
| magic
| Supported |
100%
| file
| POSIX tar archive (GNU)
| default
| |
99%
| file
| POSIX tar archive (GNU), directory nmap-2.12/, mode 40700 , uid 764 , gid 764 , size 0 , seconds 6701743031, user fyodor, group fyodor
| default
| |
98%
| file
| data
| default
| |
62%
| TrID
| TAR - Tape ARchive (GNU)
| default
| |
37%
| TrID
| TAR - Tape ARchive (directory)
| default
| |
100%
| lsar
| Tar
| default
| |
100%
| gt2
| TAR Archiv gefunden (Auflistung ist deaktiviert)
| default
| |
100%
| disktype
| GNU tar archive
| default
| |
100%
| detectItEasy
| Archive: tar
| default
| |
100%
| binwalkID
| POSIX tar archive (GNU), owner user name: "2/"
| default
| |
100%
| xdgMime
| application/x-tar
| default
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 6e 6d 61 70 2d 32 2e 31 | 32 2f 00 00 00 00 00 00 |nmap-2.1|2/......|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000050| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000060| 00 00 00 00 20 34 30 37 | 30 30 20 00 20 20 20 37 |.... 407|00 . 7|
|00000070| 36 34 20 00 20 20 20 37 | 36 34 20 00 20 20 20 20 |64 . 7|64 . |
|00000080| 20 20 20 20 20 20 30 20 | 20 36 37 30 31 37 34 33 | 0 | 6701743|
|00000090| 30 33 31 20 20 31 31 33 | 34 32 00 20 35 00 00 00 |031 113|42. 5...|
|000000a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000100| 00 75 73 74 61 72 20 20 | 00 66 79 6f 64 6f 72 00 |.ustar |.fyodor.|
|00000110| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000120| 00 00 00 00 00 00 00 00 | 00 66 79 6f 64 6f 72 00 |........|.fyodor.|
|00000130| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000140| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000150| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000160| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000170| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000180| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000190| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000200| 6e 6d 61 70 2d 32 2e 31 | 32 2f 6e 6d 61 70 2e 63 |nmap-2.1|2/nmap.c|
|00000210| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000220| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000230| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000240| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000250| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000260| 00 00 00 00 31 30 30 36 | 30 30 20 00 20 20 20 37 |....1006|00 . 7|
|00000270| 36 34 20 00 20 20 20 37 | 36 34 20 00 20 20 20 20 |64 . 7|64 . |
|00000280| 20 33 33 30 33 36 32 20 | 20 36 37 30 31 36 31 32 | 330362 | 6701612|
|00000290| 36 35 34 20 20 31 32 36 | 31 35 00 20 30 00 00 00 |654 126|15. 0...|
|000002a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000300| 00 75 73 74 61 72 20 20 | 00 66 79 6f 64 6f 72 00 |.ustar |.fyodor.|
|00000310| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000320| 00 00 00 00 00 00 00 00 | 00 66 79 6f 64 6f 72 00 |........|.fyodor.|
|00000330| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000340| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000350| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000360| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000370| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000380| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000390| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000400| 23 69 6e 63 6c 75 64 65 | 20 22 6e 6d 61 70 2e 68 |#include| "nmap.h|
|00000410| 22 0a 23 69 6e 63 6c 75 | 64 65 20 22 6f 73 73 63 |".#inclu|de "ossc|
|00000420| 61 6e 2e 68 22 0a 0a 2f | 2a 20 67 6c 6f 62 61 6c |an.h"../|* global|
|00000430| 20 6f 70 74 69 6f 6e 73 | 20 2a 2f 0a 65 78 74 65 | options| */.exte|
|00000440| 72 6e 20 63 68 61 72 20 | 2a 6f 70 74 61 72 67 3b |rn char |*optarg;|
|00000450| 0a 65 78 74 65 72 6e 20 | 69 6e 74 20 6f 70 74 69 |.extern |int opti|
|00000460| 6e 64 3b 0a 73 74 72 75 | 63 74 20 6f 70 73 20 6f |nd;.stru|ct ops o|
|00000470| 3b 20 20 2f 2a 20 6f 70 | 74 69 6f 6e 20 73 74 72 |; /* op|tion str|
|00000480| 75 63 74 75 72 65 20 2a | 2f 0a 0a 69 6e 74 20 6d |ucture *|/..int m|
|00000490| 61 69 6e 28 69 6e 74 20 | 61 72 67 63 2c 20 63 68 |ain(int |argc, ch|
|000004a0| 61 72 20 2a 61 72 67 76 | 5b 5d 29 20 7b 0a 63 68 |ar *argv|[]) {.ch|
|000004b0| 61 72 20 2a 70 2c 20 2a | 71 3b 0a 69 6e 74 20 69 |ar *p, *|q;.int i|
|000004c0| 2c 20 6a 2c 20 61 72 67 | 2c 20 61 72 67 76 6c 65 |, j, arg|, argvle|
|000004d0| 6e 3b 0a 46 49 4c 45 20 | 2a 69 6e 70 75 74 66 64 |n;.FILE |*inputfd|
|000004e0| 20 3d 20 4e 55 4c 4c 3b | 0a 63 68 61 72 20 2a 68 | = NULL;|.char *h|
|000004f0| 6f 73 74 5f 73 70 65 63 | 3b 0a 73 68 6f 72 74 20 |ost_spec|;.short |
|00000500| 66 61 73 74 73 63 61 6e | 3d 30 2c 20 72 61 6e 64 |fastscan|=0, rand|
|00000510| 6f 6d 69 7a 65 3d 31 2c | 20 72 65 73 6f 6c 76 65 |omize=1,| resolve|
|00000520| 5f 61 6c 6c 3d 30 3b 0a | 73 68 6f 72 74 20 71 75 |_all=0;.|short qu|
|00000530| 61 73 68 61 72 67 76 20 | 3d 20 30 3b 0a 69 6e 74 |ashargv |= 0;.int|
|00000540| 20 6e 75 6d 68 6f 73 74 | 73 5f 73 63 61 6e 6e 65 | numhost|s_scanne|
|00000550| 64 20 3d 20 30 3b 0a 69 | 6e 74 20 6e 75 6d 68 6f |d = 0;.i|nt numho|
|00000560| 73 74 73 5f 75 70 20 3d | 20 30 3b 0a 69 6e 74 20 |sts_up =| 0;.int |
|00000570| 73 74 61 72 74 74 69 6d | 65 3b 0a 73 74 72 75 63 |starttim|e;.struc|
|00000580| 74 20 74 69 6d 65 76 61 | 6c 20 74 76 3b 20 2f 2a |t timeva|l tv; /*|
|00000590| 20 4a 75 73 74 20 66 6f | 72 20 73 65 65 64 69 6e | Just fo|r seedin|
|000005a0| 67 20 72 61 6e 64 6f 6d | 20 67 65 6e 65 72 61 74 |g random| generat|
|000005b0| 6f 72 20 2a 2f 0a 75 6e | 73 69 67 6e 65 64 20 73 |or */.un|signed s|
|000005c0| 68 6f 72 74 20 2a 70 6f | 72 74 73 20 3d 20 4e 55 |hort *po|rts = NU|
|000005d0| 4c 4c 3b 0a 63 68 61 72 | 20 6d 79 6e 61 6d 65 5b |LL;.char| myname[|
|000005e0| 4d 41 58 48 4f 53 54 4e | 41 4d 45 4c 45 4e 20 2b |MAXHOSTN|AMELEN +|
|000005f0| 20 31 5d 3b 0a 23 69 66 | 20 28 64 65 66 69 6e 65 | 1];.#if| (define|
|00000600| 64 28 49 4e 5f 41 44 44 | 52 5f 44 45 45 50 53 54 |d(IN_ADD|R_DEEPST|
|00000610| 52 55 43 54 29 20 7c 7c | 20 64 65 66 69 6e 65 64 |RUCT) ||| defined|
|00000620| 28 20 53 4f 4c 41 52 49 | 53 29 29 0a 2f 2a 20 4e |( SOLARI|S))./* N|
|00000630| 6f 74 65 20 74 68 61 74 | 20 73 74 72 75 63 74 20 |ote that| struct |
|00000640| 69 6e 5f 61 64 64 72 20 | 69 6e 20 73 6f 6c 61 72 |in_addr |in solar|
|00000650| 69 73 20 69 73 20 33 20 | 6c 65 76 65 6c 73 20 64 |is is 3 |levels d|
|00000660| 65 65 70 20 6a 75 73 74 | 20 74 6f 20 73 74 6f 72 |eep just| to stor|
|00000670| 65 20 61 6e 0a 20 2a 20 | 75 6e 73 69 67 6e 65 64 |e an. * |unsigned|
|00000680| 20 69 6e 74 21 20 2a 2f | 0a 73 74 72 75 63 74 20 | int! */|.struct |
|00000690| 66 74 70 69 6e 66 6f 20 | 66 74 70 20 3d 20 7b 20 |ftpinfo |ftp = { |
|000006a0| 46 54 50 55 53 45 52 2c | 20 46 54 50 50 41 53 53 |FTPUSER,| FTPPASS|
|000006b0| 2c 20 22 22 2c 20 20 7b | 20 7b 20 7b 20 30 20 7d |, "", {| { { 0 }|
|000006c0| 20 7d 20 7d 20 2c 20 32 | 31 2c 20 30 7d 3b 0a 23 | } } , 2|1, 0};.#|
|000006d0| 65 6c 73 65 0a 73 74 72 | 75 63 74 20 66 74 70 69 |else.str|uct ftpi|
|000006e0| 6e 66 6f 20 66 74 70 20 | 3d 20 7b 20 46 54 50 55 |nfo ftp |= { FTPU|
|000006f0| 53 45 52 2c 20 46 54 50 | 50 41 53 53 2c 20 22 22 |SER, FTP|PASS, ""|
|00000700| 2c 20 7b 20 30 20 7d 2c | 20 32 31 2c 20 30 7d 3b |, { 0 },| 21, 0};|
|00000710| 0a 23 65 6e 64 69 66 0a | 73 74 72 75 63 74 20 68 |.#endif.|struct h|
|00000720| 6f 73 74 65 6e 74 20 2a | 74 61 72 67 65 74 20 3d |ostent *|target =|
|00000730| 20 4e 55 4c 4c 3b 0a 63 | 68 61 72 20 2a 2a 66 61 | NULL;.c|har **fa|
|00000740| 6b 65 61 72 67 76 20 3d | 20 28 63 68 61 72 20 2a |keargv =| (char *|
|00000750| 2a 29 20 73 61 66 65 5f | 6d 61 6c 6c 6f 63 28 73 |*) safe_|malloc(s|
|00000760| 69 7a 65 6f 66 28 63 68 | 61 72 20 2a 29 20 2a 20 |izeof(ch|ar *) * |
|00000770| 28 61 72 67 63 20 2b 20 | 31 29 29 3b 0a 73 74 72 |(argc + |1));.str|
|00000780| 75 63 74 20 68 6f 73 74 | 73 74 72 75 63 74 20 2a |uct host|struct *|
|00000790| 63 75 72 72 65 6e 74 68 | 73 3b 0a 63 68 61 72 20 |currenth|s;.char |
|000007a0| 65 6d 70 74 79 73 74 72 | 69 6e 67 5b 31 5d 3b 0a |emptystr|ing[1];.|
|000007b0| 69 6e 74 20 73 6f 75 72 | 63 65 61 64 64 72 77 61 |int sour|ceaddrwa|
|000007c0| 72 6e 69 6e 67 20 3d 20 | 30 3b 20 2f 2a 20 48 61 |rning = |0; /* Ha|
|000007d0| 76 65 20 77 65 20 77 61 | 72 6e 65 64 20 74 68 65 |ve we wa|rned the|
|000007e0| 6d 20 79 65 74 20 61 62 | 6f 75 74 20 75 6e 67 75 |m yet ab|out ungu|
|000007f0| 65 73 73 61 62 6c 65 0a | 09 09 09 20 20 20 20 20 |essable.|... |
|00000800| 20 73 6f 75 72 63 65 20 | 61 64 64 72 65 73 73 65 | source |addresse|
|00000810| 73 3f 20 2a 2f 0a 0a 2f | 2a 20 54 72 61 70 20 74 |s? */../|* Trap t|
|00000820| 68 65 73 65 20 73 69 67 | 73 20 66 6f 72 20 63 6c |hese sig|s for cl|
|00000830| 65 61 6e 75 70 20 2a 2f | 0a 73 69 67 6e 61 6c 28 |eanup */|.signal(|
|00000840| 53 49 47 49 4e 54 2c 20 | 73 69 67 64 69 65 29 3b |SIGINT, |sigdie);|
|00000850| 0a 73 69 67 6e 61 6c 28 | 53 49 47 54 45 52 4d 2c |.signal(|SIGTERM,|
|00000860| 20 73 69 67 64 69 65 29 | 3b 0a 73 69 67 6e 61 6c | sigdie)|;.signal|
|00000870| 28 53 49 47 48 55 50 2c | 20 73 69 67 64 69 65 29 |(SIGHUP,| sigdie)|
|00000880| 3b 20 0a 69 66 20 28 21 | 6f 2e 64 65 62 75 67 67 |; .if (!|o.debugg|
|00000890| 69 6e 67 29 0a 20 20 73 | 69 67 6e 61 6c 28 53 49 |ing). s|ignal(SI|
|000008a0| 47 53 45 47 56 2c 20 73 | 69 67 64 69 65 29 3b 20 |GSEGV, s|igdie); |
|000008b0| 0a 0a 0a 0a 23 69 66 64 | 65 66 20 52 4f 55 54 45 |....#ifd|ef ROUTE|
|000008c0| 54 48 52 4f 55 47 48 54 | 45 53 54 0a 2f 2a 20 52 |THROUGHT|EST./* R|
|000008d0| 6f 75 74 65 74 68 72 6f | 75 67 68 20 73 74 75 70 |outethro|ugh stup|
|000008e0| 68 20 2d 2d 20 6b 69 6c | 6c 20 6c 61 74 65 72 20 |h -- kil|l later |
|000008f0| 2a 2f 0a 7b 0a 63 68 61 | 72 20 2a 64 65 76 3b 0a |*/.{.cha|r *dev;.|
|00000900| 73 74 72 75 63 74 20 69 | 6e 5f 61 64 64 72 20 64 |struct i|n_addr d|
|00000910| 65 73 74 3b 0a 73 74 72 | 75 63 74 20 69 6e 5f 61 |est;.str|uct in_a|
|00000920| 64 64 72 20 73 6f 75 72 | 63 65 3b 0a 69 66 20 28 |ddr sour|ce;.if (|
|00000930| 21 72 65 73 6f 6c 76 65 | 28 61 72 67 76 5b 31 5d |!resolve|(argv[1]|
|00000940| 2c 20 26 64 65 73 74 29 | 29 0a 20 20 66 61 74 61 |, &dest)|). fata|
|00000950| 6c 28 22 46 61 69 6c 65 | 64 20 74 6f 20 72 65 73 |l("Faile|d to res|
|00000960| 6f 6c 76 65 20 25 73 5c | 6e 22 2c 20 61 72 67 76 |olve %s\|n", argv|
|00000970| 5b 31 5d 29 3b 0a 64 65 | 76 20 3d 20 72 6f 75 74 |[1]);.de|v = rout|
|00000980| 65 74 68 72 6f 75 67 68 | 28 26 64 65 73 74 2c 20 |ethrough|(&dest, |
|00000990| 26 73 6f 75 72 63 65 29 | 3b 0a 69 66 20 28 64 65 |&source)|;.if (de|
|000009a0| 76 29 0a 20 20 66 70 72 | 69 6e 74 66 28 6f 2e 6e |v). fpr|intf(o.n|
|000009b0| 6d 61 70 5f 73 74 64 6f | 75 74 2c 20 22 25 73 20 |map_stdo|ut, "%s |
|000009c0| 72 6f 75 74 65 73 20 74 | 68 72 6f 75 67 68 20 64 |routes t|hrough d|
|000009d0| 65 76 69 63 65 20 25 73 | 20 75 73 69 6e 67 20 49 |evice %s| using I|
|000009e0| 50 20 61 64 64 72 65 73 | 73 20 25 73 5c 6e 22 2c |P addres|s %s\n",|
|000009f0| 20 61 72 67 76 5b 31 5d | 2c 20 64 65 76 2c 20 69 | argv[1]|, dev, i|
|00000a00| 6e 65 74 5f 6e 74 6f 61 | 28 73 6f 75 72 63 65 29 |net_ntoa|(source)|
|00000a10| 29 3b 0a 65 6c 73 65 20 | 66 70 72 69 6e 74 66 28 |);.else |fprintf(|
|00000a20| 6f 2e 6e 6d 61 70 5f 73 | 74 64 6f 75 74 2c 20 22 |o.nmap_s|tdout, "|
|00000a30| 43 6f 75 6c 64 20 6e 6f | 74 20 64 65 74 65 72 6d |Could no|t determ|
|00000a40| 69 6e 65 20 77 68 69 63 | 68 20 64 65 76 69 63 65 |ine whic|h device|
|00000a50| 20 74 6f 20 72 6f 75 74 | 65 20 74 68 72 6f 75 67 | to rout|e throug|
|00000a60| 68 20 66 6f 72 20 25 73 | 21 21 21 5c 6e 22 2c 20 |h for %s|!!!\n", |
|00000a70| 61 72 67 76 5b 31 5d 29 | 3b 0a 0a 65 78 69 74 28 |argv[1])|;..exit(|
|00000a80| 30 29 3b 0a 7d 0a 23 65 | 6e 64 69 66 0a 0a 2f 2a |0);.}.#e|ndif../*|
|00000a90| 20 61 72 67 76 20 66 61 | 6b 69 6e 67 20 73 69 6c | argv fa|king sil|
|00000aa0| 6c 69 6e 65 73 73 20 2a | 2f 0a 66 6f 72 28 69 3d |liness *|/.for(i=|
|00000ab0| 30 3b 20 69 20 3c 20 61 | 72 67 63 3b 20 69 2b 2b |0; i < a|rgc; i++|
|00000ac0| 29 20 7b 0a 20 20 66 61 | 6b 65 61 72 67 76 5b 69 |) {. fa|keargv[i|
|00000ad0| 5d 20 3d 20 73 61 66 65 | 5f 6d 61 6c 6c 6f 63 28 |] = safe|_malloc(|
|00000ae0| 73 74 72 6c 65 6e 28 61 | 72 67 76 5b 69 5d 29 20 |strlen(a|rgv[i]) |
|00000af0| 2b 20 31 29 3b 0a 20 20 | 73 74 72 6e 63 70 79 28 |+ 1);. |strncpy(|
|00000b00| 66 61 6b 65 61 72 67 76 | 5b 69 5d 2c 20 61 72 67 |fakeargv|[i], arg|
|00000b10| 76 5b 69 5d 2c 20 73 74 | 72 6c 65 6e 28 61 72 67 |v[i], st|rlen(arg|
|00000b20| 76 5b 69 5d 29 20 2b 20 | 31 29 3b 0a 7d 0a 66 61 |v[i]) + |1);.}.fa|
|00000b30| 6b 65 61 72 67 76 5b 61 | 72 67 63 5d 20 3d 20 4e |keargv[a|rgc] = N|
|00000b40| 55 4c 4c 3b 0a 0a 0a 0a | 2f 2a 20 53 65 65 64 20 |ULL;....|/* Seed |
|00000b50| 6f 75 72 20 72 61 6e 64 | 6f 6d 20 67 65 6e 65 72 |our rand|om gener|
|00000b60| 61 74 6f 72 20 2a 2f 0a | 67 65 74 74 69 6d 65 6f |ator */.|gettimeo|
|00000b70| 66 64 61 79 28 26 74 76 | 2c 20 4e 55 4c 4c 29 3b |fday(&tv|, NULL);|
|00000b80| 0a 69 66 20 28 74 76 2e | 74 76 5f 75 73 65 63 29 |.if (tv.|tv_usec)|
|00000b90| 20 73 72 61 6e 64 28 74 | 76 2e 74 76 5f 75 73 65 | srand(t|v.tv_use|
|00000ba0| 63 29 3b 0a 65 6c 73 65 | 20 69 66 20 28 74 76 2e |c);.else| if (tv.|
|00000bb0| 74 76 5f 73 65 63 29 20 | 73 72 61 6e 64 28 74 76 |tv_sec) |srand(tv|
|00000bc0| 2e 74 76 5f 73 65 63 29 | 3b 0a 65 6c 73 65 20 73 |.tv_sec)|;.else s|
|00000bd0| 72 61 6e 64 28 74 69 6d | 65 28 4e 55 4c 4c 29 29 |rand(tim|e(NULL))|
|00000be0| 3b 0a 0a 2f 2a 20 69 6e | 69 74 69 61 6c 69 7a 65 |;../* in|itialize|
|00000bf0| 20 6f 75 72 20 6f 70 74 | 69 6f 6e 73 20 2a 2f 0a | our opt|ions */.|
|00000c00| 6f 70 74 69 6f 6e 73 5f | 69 6e 69 74 28 29 3b 0a |options_|init();.|
|00000c10| 0a 65 6d 70 74 79 73 74 | 72 69 6e 67 5b 30 5d 20 |.emptyst|ring[0] |
|00000c20| 3d 20 27 5c 30 27 3b 20 | 2f 2a 20 49 74 20 77 6f |= '\0'; |/* It wo|
|00000c30| 75 6c 64 6e 27 74 20 62 | 65 20 61 6e 20 65 6d 70 |uldn't b|e an emp|
|00000c40| 74 79 73 74 72 69 6e 67 | 20 77 2f 6f 20 74 68 69 |tystring| w/o thi|
|00000c50| 73 20 3b 29 20 2a 2f 0a | 0a 0a 69 66 20 28 61 72 |s ;) */.|..if (ar|
|00000c60| 67 63 20 3c 20 32 20 29 | 20 70 72 69 6e 74 75 73 |gc < 2 )| printus|
|00000c70| 61 67 65 28 61 72 67 76 | 5b 30 5d 29 3b 0a 0a 2f |age(argv|[0]);../|
|00000c80| 2a 20 4f 4b 2c 20 6c 65 | 74 73 20 70 61 72 73 65 |* OK, le|ts parse|
|00000c90| 20 74 68 65 73 65 20 61 | 72 67 73 21 20 2a 2f 0a | these a|rgs! */.|
|00000ca0| 77 68 69 6c 65 28 28 61 | 72 67 20 3d 20 67 65 74 |while((a|rg = get|
|00000cb0| 6f 70 74 28 61 72 67 63 | 2c 66 61 6b 65 61 72 67 |opt(argc|,fakearg|
|00000cc0| 76 2c 22 41 62 3a 44 3a | 64 65 3a 46 66 67 3a 68 |v,"Ab:D:|de:Ffg:h|
|00000cd0| 49 69 3a 4d 3a 6d 3a 4e | 6e 4f 6f 3a 50 3a 70 3a |Ii:M:m:N|nOo:P:p:|
|00000ce0| 71 52 72 53 3a 73 3a 54 | 3a 56 76 22 29 29 20 21 |qRrS:s:T|:Vv")) !|
|00000cf0| 3d 20 45 4f 46 29 20 7b | 0a 20 20 73 77 69 74 63 |= EOF) {|. switc|
|00000d00| 68 28 61 72 67 29 20 7b | 0a 20 20 63 61 73 65 20 |h(arg) {|. case |
|00000d10| 27 41 27 3a 20 6f 2e 61 | 6c 6c 6f 77 61 6c 6c 2b |'A': o.a|llowall+|
|00000d20| 2b 3b 20 62 72 65 61 6b | 3b 0a 20 20 63 61 73 65 |+; break|;. case|
|00000d30| 20 27 62 27 3a 20 0a 20 | 20 20 20 6f 2e 62 6f 75 | 'b': . | o.bou|
|00000d40| 6e 63 65 73 63 61 6e 2b | 2b 3b 0a 20 20 20 20 69 |ncescan+|+;. i|
|00000d50| 66 20 28 70 61 72 73 65 | 5f 62 6f 75 6e 63 65 28 |f (parse|_bounce(|
|00000d60| 26 66 74 70 2c 20 6f 70 | 74 61 72 67 29 20 3c 20 |&ftp, op|targ) < |
|00000d70| 30 20 29 20 7b 0a 20 20 | 20 20 20 20 66 70 72 69 |0 ) {. | fpri|
|00000d80| 6e 74 66 28 73 74 64 65 | 72 72 2c 20 22 59 6f 75 |ntf(stde|rr, "You|
|00000d90| 72 20 61 72 67 75 6d 65 | 6e 74 20 74 6f 20 2d 62 |r argume|nt to -b|
|00000da0| 20 69 73 20 66 75 63 6b | 65 64 20 75 70 2e 20 55 | is fuck|ed up. U|
|00000db0| 73 65 20 74 68 65 20 6e | 6f 72 6d 61 6c 20 75 72 |se the n|ormal ur|
|00000dc0| 6c 20 73 74 79 6c 65 3a | 20 20 75 73 65 72 3a 70 |l style:| user:p|
|00000dd0| 61 73 73 40 73 65 72 76 | 65 72 3a 70 6f 72 74 20 |ass@serv|er:port |
|00000de0| 6f 72 20 6a 75 73 74 20 | 75 73 65 20 73 65 72 76 |or just |use serv|
|00000df0| 65 72 20 61 6e 64 20 75 | 73 65 20 64 65 66 61 75 |er and u|se defau|
|00000e00| 6c 74 20 61 6e 6f 6e 20 | 6c 6f 67 69 6e 5c 6e 20 |lt anon |login\n |
|00000e10| 20 55 73 65 20 2d 68 20 | 66 6f 72 20 68 65 6c 70 | Use -h |for help|
|00000e20| 5c 6e 22 29 3b 0a 20 20 | 20 20 7d 0a 20 20 20 20 |\n");. | }. |
|00000e30| 62 72 65 61 6b 3b 0a 20 | 20 63 61 73 65 20 27 44 |break;. | case 'D|
|00000e40| 27 3a 0a 20 20 20 20 70 | 20 3d 20 6f 70 74 61 72 |':. p| = optar|
|00000e50| 67 3b 0a 20 20 20 20 64 | 6f 20 7b 20 20 20 20 0a |g;. d|o { .|
|00000e60| 20 20 20 20 20 20 71 20 | 3d 20 73 74 72 63 68 72 | q |= strchr|
|00000e70| 28 70 2c 20 27 2c 27 29 | 3b 0a 20 20 20 20 20 20 |(p, ',')|;. |
|00000e80| 69 66 20 28 71 29 20 2a | 71 20 3d 20 27 5c 30 27 |if (q) *|q = '\0'|
|00000e90| 3b 0a 20 20 20 20 20 20 | 69 66 20 28 21 73 74 72 |;. |if (!str|
|00000ea0| 63 61 73 65 63 6d 70 28 | 70 2c 20 22 6d 65 22 29 |casecmp(|p, "me")|
|00000eb0| 29 20 7b 0a 09 69 66 20 | 28 6f 2e 64 65 63 6f 79 |) {..if |(o.decoy|
|00000ec0| 74 75 72 6e 20 21 3d 20 | 2d 31 29 20 0a 09 20 20 |turn != |-1) .. |
|00000ed0| 66 61 74 61 6c 28 22 43 | 61 6e 20 6f 6e 6c 79 20 |fatal("C|an only |
|00000ee0| 75 73 65 20 27 4d 45 27 | 20 61 73 20 61 20 64 65 |use 'ME'| as a de|
|00000ef0| 63 6f 79 20 6f 6e 63 65 | 2e 5c 6e 22 29 3b 0a 09 |coy once|.\n");..|
|00000f00| 6f 2e 64 65 63 6f 79 74 | 75 72 6e 20 3d 20 6f 2e |o.decoyt|urn = o.|
|00000f10| 6e 75 6d 64 65 63 6f 79 | 73 2b 2b 3b 0a 20 20 20 |numdecoy|s++;. |
|00000f20| 20 20 20 7d 20 65 6c 73 | 65 20 7b 20 20 20 20 20 | } els|e { |
|00000f30| 20 0a 09 69 66 20 28 6f | 2e 6e 75 6d 64 65 63 6f | ..if (o|.numdeco|
|00000f40| 79 73 20 3e 3d 20 4d 41 | 58 5f 44 45 43 4f 59 53 |ys >= MA|X_DECOYS|
|00000f50| 20 2d 31 29 0a 09 20 20 | 66 61 74 61 6c 28 22 59 | -1).. |fatal("Y|
|00000f60| 6f 75 20 61 72 65 20 6f | 6e 6c 79 20 61 6c 6c 6f |ou are o|nly allo|
|00000f70| 77 65 64 20 25 64 20 64 | 65 63 6f 79 73 20 28 69 |wed %d d|ecoys (i|
|00000f80| 66 20 79 6f 75 20 6e 65 | 65 64 20 6d 6f 72 65 20 |f you ne|ed more |
|00000f90| 72 65 64 65 66 69 6e 65 | 20 4d 41 58 5f 44 45 43 |redefine| MAX_DEC|
|00000fa0| 4f 59 53 20 69 6e 20 6e | 6d 61 70 2e 68 29 22 29 |OYS in n|map.h)")|
|00000fb0| 3b 0a 09 69 66 20 28 72 | 65 73 6f 6c 76 65 28 70 |;..if (r|esolve(p|
|00000fc0| 2c 20 26 6f 2e 64 65 63 | 6f 79 73 5b 6f 2e 6e 75 |, &o.dec|oys[o.nu|
|00000fd0| 6d 64 65 63 6f 79 73 5d | 29 29 20 7b 0a 09 20 20 |mdecoys]|)) {.. |
|00000fe0| 6f 2e 6e 75 6d 64 65 63 | 6f 79 73 2b 2b 3b 0a 09 |o.numdec|oys++;..|
|00000ff0| 7d 20 65 6c 73 65 20 7b | 0a 09 20 20 66 61 74 61 |} else {|.. fata|
|00001000| 6c 28 22 46 61 69 6c 65 | 64 20 74 6f 20 72 65 73 |l("Faile|d to res|
|00001010| 6f 6c 76 65 20 64 65 63 | 6f 79 20 68 6f 73 74 3a |olve dec|oy host:|
|00001020| 20 25 73 20 28 6d 75 73 | 74 20 62 65 20 68 6f 73 | %s (mus|t be hos|
|00001030| 74 6e 61 6d 65 20 6f 72 | 20 49 50 20 61 64 64 72 |tname or| IP addr|
|00001040| 65 73 73 22 2c 20 6f 70 | 74 61 72 67 29 3b 0a 09 |ess", op|targ);..|
|00001050| 7d 0a 20 20 20 20 20 20 | 7d 0a 20 20 20 20 20 20 |}. |}. |
|00001060| 69 66 20 28 71 29 20 7b | 0a 09 2a 71 20 3d 20 27 |if (q) {|..*q = '|
|00001070| 2c 27 3b 0a 09 70 20 3d | 20 71 2b 31 3b 0a 20 20 |,';..p =| q+1;. |
|00001080| 20 20 20 20 7d 0a 20 20 | 20 20 7d 20 77 68 69 6c | }. | } whil|
|00001090| 65 28 71 29 3b 0a 20 20 | 20 20 62 72 65 61 6b 3b |e(q);. | break;|
|000010a0| 0a 20 20 63 61 73 65 20 | 27 64 27 3a 20 6f 2e 64 |. case |'d': o.d|
|000010b0| 65 62 75 67 67 69 6e 67 | 2b 2b 3b 20 6f 2e 76 65 |ebugging|++; o.ve|
|000010c0| 72 62 6f 73 65 2b 2b 3b | 20 62 72 65 61 6b 3b 0a |rbose++;| break;.|
|000010d0| 20 20 63 61 73 65 20 27 | 65 27 3a 20 0a 20 20 20 | case '|e': . |
|000010e0| 20 73 74 72 6e 63 70 79 | 28 6f 2e 64 65 76 69 63 | strncpy|(o.devic|
|000010f0| 65 2c 20 6f 70 74 61 72 | 67 2c 36 33 29 3b 20 6f |e, optar|g,63); o|
|00001100| 2e 64 65 76 69 63 65 5b | 36 33 5d 20 3d 20 27 5c |.device[|63] = '\|
|00001110| 30 27 3b 20 62 72 65 61 | 6b 3b 0a 20 20 63 61 73 |0'; brea|k;. cas|
|00001120| 65 20 27 46 27 3a 20 66 | 61 73 74 73 63 61 6e 2b |e 'F': f|astscan+|
|00001130| 2b 3b 20 62 72 65 61 6b | 3b 0a 20 20 63 61 73 65 |+; break|;. case|
|00001140| 20 27 66 27 3a 20 6f 2e | 66 72 61 67 73 63 61 6e | 'f': o.|fragscan|
|00001150| 2b 2b 3b 20 62 72 65 61 | 6b 3b 0a 20 20 63 61 73 |++; brea|k;. cas|
|00001160| 65 20 27 67 27 3a 20 0a | 20 20 20 20 6f 2e 6d 61 |e 'g': .| o.ma|
|00001170| 67 69 63 5f 70 6f 72 74 | 20 3d 20 61 74 6f 69 28 |gic_port| = atoi(|
|00001180| 6f 70 74 61 72 67 29 3b | 0a 20 20 20 20 6f 2e 6d |optarg);|. o.m|
|00001190| 61 67 69 63 5f 70 6f 72 | 74 5f 73 65 74 20 3d 20 |agic_por|t_set = |
|000011a0| 31 3b 0a 20 20 20 20 69 | 66 20 28 21 6f 2e 6d 61 |1;. i|f (!o.ma|
|000011b0| 67 69 63 5f 70 6f 72 74 | 29 20 66 61 74 61 6c 28 |gic_port|) fatal(|
|000011c0| 22 2d 67 20 6e 65 65 64 | 73 20 6e 6f 6e 7a 65 72 |"-g need|s nonzer|
|000011d0| 6f 20 61 72 67 75 6d 65 | 6e 74 22 29 3b 0a 20 20 |o argume|nt");. |
|000011e0| 20 20 62 72 65 61 6b 3b | 20 20 20 20 0a 20 20 63 | break;| . c|
|000011f0| 61 73 65 20 27 68 27 3a | 20 0a 20 20 63 61 73 65 |ase 'h':| . case|
|00001200| 20 27 3f 27 3a 20 70 72 | 69 6e 74 75 73 61 67 65 | '?': pr|intusage|
|00001210| 28 61 72 67 76 5b 30 5d | 29 3b 20 62 72 65 61 6b |(argv[0]|); break|
|00001220| 3b 0a 20 20 63 61 73 65 | 20 27 49 27 3a 20 6f 2e |;. case| 'I': o.|
|00001230| 69 64 65 6e 74 73 63 61 | 6e 2b 2b 3b 20 62 72 65 |identsca|n++; bre|
|00001240| 61 6b 3b 0a 20 20 63 61 | 73 65 20 27 69 27 3a 20 |ak;. ca|se 'i': |
|00001250| 0a 20 20 20 20 69 66 20 | 28 69 6e 70 75 74 66 64 |. if |(inputfd|
|00001260| 29 20 7b 0a 20 20 20 20 | 20 20 66 61 74 61 6c 28 |) {. | fatal(|
|00001270| 22 4f 6e 6c 79 20 6f 6e | 65 20 69 6e 70 75 74 20 |"Only on|e input |
|00001280| 66 69 6c 65 6e 61 6d 65 | 20 61 6c 6c 6f 77 65 64 |filename| allowed|
|00001290| 22 29 3b 0a 20 20 20 20 | 7d 0a 20 20 20 20 69 66 |");. |}. if|
|000012a0| 20 28 21 73 74 72 63 6d | 70 28 6f 70 74 61 72 67 | (!strcm|p(optarg|
|000012b0| 2c 20 22 2d 22 29 29 20 | 7b 0a 20 20 20 20 20 20 |, "-")) |{. |
|000012c0| 69 6e 70 75 74 66 64 20 | 3d 20 73 74 64 69 6e 3b |inputfd |= stdin;|
|000012d0| 0a 20 20 20 20 20 20 66 | 70 72 69 6e 74 66 28 6f |. f|printf(o|
|000012e0| 2e 6e 6d 61 70 5f 73 74 | 64 6f 75 74 2c 20 22 52 |.nmap_st|dout, "R|
|000012f0| 65 61 64 69 6e 67 20 74 | 61 72 67 65 74 20 73 70 |eading t|arget sp|
|00001300| 65 63 69 66 69 63 61 74 | 69 6f 6e 73 20 66 72 6f |ecificat|ions fro|
|00001310| 6d 20 73 74 64 69 6e 5c | 6e 22 29 3b 0a 20 20 20 |m stdin\|n");. |
|00001320| 20 7d 20 65 6c 73 65 20 | 7b 20 20 20 20 0a 20 20 | } else |{ . |
|00001330| 20 20 20 20 69 6e 70 75 | 74 66 64 20 3d 20 66 6f | inpu|tfd = fo|
|00001340| 70 65 6e 28 6f 70 74 61 | 72 67 2c 20 22 72 22 29 |pen(opta|rg, "r")|
|00001350| 3b 0a 20 20 20 20 20 20 | 69 66 20 28 21 69 6e 70 |;. |if (!inp|
|00001360| 75 74 66 64 29 20 7b 0a | 09 66 61 74 61 6c 28 22 |utfd) {.|.fatal("|
|00001370| 46 61 69 6c 65 64 20 74 | 6f 20 6f 70 65 6e 20 69 |Failed t|o open i|
|00001380| 6e 70 75 74 20 66 69 6c | 65 20 25 73 20 66 6f 72 |nput fil|e %s for|
|00001390| 20 72 65 61 64 69 6e 67 | 22 2c 20 6f 70 74 61 72 | reading|", optar|
|000013a0| 67 29 3b 0a 20 20 20 20 | 20 20 7d 20 20 0a 20 20 |g);. | } . |
|000013b0| 20 20 20 20 66 70 72 69 | 6e 74 66 28 6f 2e 6e 6d | fpri|ntf(o.nm|
|000013c0| 61 70 5f 73 74 64 6f 75 | 74 2c 20 22 52 65 61 64 |ap_stdou|t, "Read|
|000013d0| 69 6e 67 20 74 61 72 67 | 65 74 20 73 70 65 63 69 |ing targ|et speci|
|000013e0| 66 69 63 61 74 69 6f 6e | 73 20 66 72 6f 6d 20 46 |fication|s from F|
|000013f0| 49 4c 45 3a 20 25 73 5c | 6e 22 2c 20 6f 70 74 61 |ILE: %s\|n", opta|
|00001400| 72 67 29 3b 0a 20 20 20 | 20 7d 0a 20 20 20 20 62 |rg);. | }. b|
|00001410| 72 65 61 6b 3b 20 20 0a | 20 20 63 61 73 65 20 27 |reak; .| case '|
|00001420| 4d 27 3a 20 0a 20 20 20 | 20 6f 2e 6d 61 78 5f 73 |M': . | o.max_s|
|00001430| 6f 63 6b 65 74 73 20 3d | 20 61 74 6f 69 28 6f 70 |ockets =| atoi(op|
|00001440| 74 61 72 67 29 3b 20 0a | 20 20 20 20 69 66 20 28 |targ); .| if (|
|00001450| 6f 2e 6d 61 78 5f 73 6f | 63 6b 65 74 73 20 3c 20 |o.max_so|ckets < |
|00001460| 31 29 20 66 61 74 61 6c | 28 22 41 72 67 75 6d 65 |1) fatal|("Argume|
|00001470| 6e 74 20 74 6f 20 2d 4d | 20 6d 75 73 74 20 62 65 |nt to -M| must be|
|00001480| 20 61 74 20 6c 65 61 73 | 74 20 31 21 22 29 3b 0a | at leas|t 1!");.|
|00001490| 20 20 20 20 69 66 20 28 | 6f 2e 6d 61 78 5f 73 6f | if (|o.max_so|
|000014a0| 63 6b 65 74 73 20 3e 20 | 4d 41 58 5f 53 4f 43 4b |ckets > |MAX_SOCK|
|000014b0| 45 54 53 5f 41 4c 4c 4f | 57 45 44 29 20 7b 0a 20 |ETS_ALLO|WED) {. |
|000014c0| 20 20 20 20 20 66 70 72 | 69 6e 74 66 28 73 74 64 | fpr|intf(std|
|000014d0| 65 72 72 2c 20 22 57 61 | 72 6e 69 6e 67 3a 20 59 |err, "Wa|rning: Y|
|000014e0| 6f 75 20 61 72 65 20 6c | 69 6d 69 74 65 64 20 74 |ou are l|imited t|
|000014f0| 6f 20 4d 41 58 5f 53 4f | 43 4b 45 54 53 5f 41 4c |o MAX_SO|CKETS_AL|
|00001500| 4c 4f 57 45 44 20 28 25 | 64 29 20 70 61 72 61 6c |LOWED (%|d) paral|
|00001510| 6c 65 6c 20 73 6f 63 6b | 65 74 73 2e 20 20 49 66 |lel sock|ets. If|
|00001520| 20 79 6f 75 20 72 65 61 | 6c 6c 79 20 6e 65 65 64 | you rea|lly need|
|00001530| 20 6d 6f 72 65 2c 20 63 | 68 61 6e 67 65 20 74 68 | more, c|hange th|
|00001540| 65 20 23 64 65 66 69 6e | 65 20 61 6e 64 20 72 65 |e #defin|e and re|
|00001550| 63 6f 6d 70 69 6c 65 2e | 5c 6e 22 2c 20 4d 41 58 |compile.|\n", MAX|
|00001560| 5f 53 4f 43 4b 45 54 53 | 5f 41 4c 4c 4f 57 45 44 |_SOCKETS|_ALLOWED|
|00001570| 29 3b 0a 20 20 20 20 20 | 20 6f 2e 6d 61 78 5f 73 |);. | o.max_s|
|00001580| 6f 63 6b 65 74 73 20 3d | 20 4d 41 58 5f 53 4f 43 |ockets =| MAX_SOC|
|00001590| 4b 45 54 53 5f 41 4c 4c | 4f 57 45 44 3b 0a 20 20 |KETS_ALL|OWED;. |
|000015a0| 20 20 7d 0a 20 20 20 20 | 62 72 65 61 6b 3b 0a 20 | }. |break;. |
|000015b0| 20 63 61 73 65 20 27 6d | 27 3a 20 0a 20 20 20 20 | case 'm|': . |
|000015c0| 69 66 20 28 6f 2e 6d 61 | 63 68 69 6e 65 6c 6f 67 |if (o.ma|chinelog|
|000015d0| 66 64 20 21 3d 20 4e 55 | 4c 4c 29 0a 20 20 20 20 |fd != NU|LL). |
|000015e0| 20 20 66 61 74 61 6c 28 | 22 4f 6e 6c 79 20 6f 6e | fatal(|"Only on|
|000015f0| 65 20 6d 61 63 68 69 6e | 65 20 6c 6f 67 20 66 69 |e machin|e log fi|
|00001600| 6c 65 6e 61 6d 65 20 61 | 6c 6c 6f 77 65 64 22 29 |lename a|llowed")|
|00001610| 3b 0a 20 20 20 20 69 66 | 20 28 2a 6f 70 74 61 72 |;. if| (*optar|
|00001620| 67 20 3d 3d 20 27 2d 27 | 20 26 26 20 2a 28 6f 70 |g == '-'| && *(op|
|00001630| 74 61 72 67 20 2b 20 31 | 29 20 3d 3d 20 27 5c 30 |targ + 1|) == '\0|
|00001640| 27 29 20 7b 20 20 20 20 | 0a 20 20 20 20 20 20 6f |') { |. o|
|00001650| 2e 6d 61 63 68 69 6e 65 | 6c 6f 67 66 64 20 3d 20 |.machine|logfd = |
|00001660| 73 74 64 6f 75 74 3b 0a | 20 20 20 20 20 20 6f 2e |stdout;.| o.|
|00001670| 6e 6d 61 70 5f 73 74 64 | 6f 75 74 20 3d 20 66 6f |nmap_std|out = fo|
|00001680| 70 65 6e 28 22 2f 64 65 | 76 2f 6e 75 6c 6c 22 2c |pen("/de|v/null",|
|00001690| 20 22 77 22 29 3b 0a 20 | 20 20 20 20 20 69 66 20 | "w");. | if |
|000016a0| 28 21 6f 2e 6e 6d 61 70 | 5f 73 74 64 6f 75 74 29 |(!o.nmap|_stdout)|
|000016b0| 20 7b 0a 09 66 61 74 61 | 6c 28 22 43 6f 75 6c 64 | {..fata|l("Could|
|000016c0| 20 6e 6f 74 20 6f 70 65 | 6e 20 2f 64 65 76 2f 6e | not ope|n /dev/n|
|000016d0| 75 6c 6c 20 66 6f 72 20 | 77 72 69 74 69 6e 67 20 |ull for |writing |
|000016e0| 66 6f 72 20 75 73 65 20 | 77 69 74 68 20 2d 6d 20 |for use |with -m |
|000016f0| 2d 20 22 29 3b 0a 20 20 | 20 20 20 20 7d 0a 20 20 |- ");. | }. |
|00001700| 20 20 7d 0a 20 20 20 20 | 65 6c 73 65 20 7b 20 0a | }. |else { .|
|00001710| 20 20 20 20 20 20 6f 2e | 6d 61 63 68 69 6e 65 6c | o.|machinel|
|00001720| 6f 67 66 64 20 3d 20 66 | 6f 70 65 6e 28 6f 70 74 |ogfd = f|open(opt|
|00001730| 61 72 67 2c 20 22 77 22 | 29 3b 0a 20 20 20 20 20 |arg, "w"|);. |
|00001740| 20 69 66 20 28 21 6f 2e | 6d 61 63 68 69 6e 65 6c | if (!o.|machinel|
|00001750| 6f 67 66 64 29 0a 09 66 | 61 74 61 6c 28 22 46 61 |ogfd)..f|atal("Fa|
|00001760| 69 6c 65 64 20 74 6f 20 | 6f 70 65 6e 20 6d 61 63 |iled to |open mac|
|00001770| 68 69 6e 65 20 70 61 72 | 73 65 61 62 6c 65 20 6c |hine par|seable l|
|00001780| 6f 67 20 66 69 6c 65 20 | 25 73 22 2c 20 6f 70 74 |og file |%s", opt|
|00001790| 61 72 67 29 3b 0a 20 20 | 20 20 7d 0a 20 20 20 20 |arg);. | }. |
|000017a0| 62 72 65 61 6b 3b 0a 20 | 20 63 61 73 65 20 27 4e |break;. | case 'N|
|000017b0| 27 3a 20 6f 2e 66 6f 72 | 63 65 2b 2b 3b 20 62 72 |': o.for|ce++; br|
|000017c0| 65 61 6b 3b 0a 20 20 63 | 61 73 65 20 27 6e 27 3a |eak;. c|ase 'n':|
|000017d0| 20 6f 2e 6e 6f 72 65 73 | 6f 6c 76 65 2b 2b 3b 20 | o.nores|olve++; |
|000017e0| 62 72 65 61 6b 3b 0a 20 | 20 63 61 73 65 20 27 4f |break;. | case 'O|
|000017f0| 27 3a 20 0a 20 20 20 20 | 6f 2e 6f 73 73 63 61 6e |': . |o.osscan|
|00001800| 2b 2b 3b 20 0a 20 20 20 | 20 6f 2e 72 65 66 65 72 |++; . | o.refer|
|00001810| 65 6e 63 65 5f 46 50 73 | 20 3d 20 70 61 72 73 65 |ence_FPs| = parse|
|00001820| 5f 66 69 6e 67 65 72 70 | 72 69 6e 74 5f 72 65 66 |_fingerp|rint_ref|
|00001830| 65 72 65 6e 63 65 5f 66 | 69 6c 65 28 29 3b 0a 20 |erence_f|ile();. |
|00001840| 20 20 20 62 72 65 61 6b | 3b 0a 20 20 63 61 73 65 | break|;. case|
|00001850| 20 27 6f 27 3a 20 0a 20 | 20 20 20 69 66 20 28 6f | 'o': . | if (o|
|00001860| 2e 6c 6f 67 66 64 20 21 | 3d 20 4e 55 4c 4c 29 20 |.logfd !|= NULL) |
|00001870| 66 61 74 61 6c 28 22 4f | 6e 6c 79 20 6f 6e 65 20 |fatal("O|nly one |
|00001880| 6c 6f 67 20 66 69 6c 65 | 6e 61 6d 65 20 61 6c 6c |log file|name all|
|00001890| 6f 77 65 64 22 29 3b 0a | 20 20 20 20 69 66 20 28 |owed");.| if (|
|000018a0| 2a 6f 70 74 61 72 67 20 | 3d 3d 20 27 2d 27 20 26 |*optarg |== '-' &|
|000018b0| 26 20 2a 28 6f 70 74 61 | 72 67 20 2b 20 31 29 20 |& *(opta|rg + 1) |
|000018c0| 3d 3d 20 27 5c 30 27 29 | 20 7b 20 20 20 20 0a 20 |== '\0')| { . |
|000018d0| 20 20 20 20 20 6f 2e 6c | 6f 67 66 64 20 3d 20 73 | o.l|ogfd = s|
|000018e0| 74 64 6f 75 74 3b 0a 20 | 20 20 20 20 20 6f 2e 6e |tdout;. | o.n|
|000018f0| 6d 61 70 5f 73 74 64 6f | 75 74 20 3d 20 66 6f 70 |map_stdo|ut = fop|
|00001900| 65 6e 28 22 2f 64 65 76 | 2f 6e 75 6c 6c 22 2c 20 |en("/dev|/null", |
|00001910| 22 77 22 29 3b 0a 20 20 | 20 20 20 20 69 66 20 28 |"w");. | if (|
|00001920| 21 6f 2e 6e 6d 61 70 5f | 73 74 64 6f 75 74 29 20 |!o.nmap_|stdout) |
|00001930| 7b 0a 09 66 61 74 61 6c | 28 22 43 6f 75 6c 64 20 |{..fatal|("Could |
|00001940| 6e 6f 74 20 6f 70 65 6e | 20 2f 64 65 76 2f 6e 75 |not open| /dev/nu|
|00001950| 6c 6c 20 66 6f 72 20 77 | 72 69 74 69 6e 67 20 66 |ll for w|riting f|
|00001960| 6f 72 20 75 73 65 20 77 | 69 74 68 20 2d 6d 20 2d |or use w|ith -m -|
|00001970| 20 22 29 3b 0a 20 20 20 | 20 20 20 7d 0a 20 20 20 | ");. | }. |
|00001980| 20 7d 20 65 6c 73 65 20 | 7b 20 20 20 20 0a 20 20 | } else |{ . |
|00001990| 20 20 20 20 6f 2e 6c 6f | 67 66 64 20 3d 20 66 6f | o.lo|gfd = fo|
|000019a0| 70 65 6e 28 6f 70 74 61 | 72 67 2c 20 22 77 22 29 |pen(opta|rg, "w")|
|000019b0| 3b 0a 20 20 20 20 20 20 | 69 66 20 28 21 6f 2e 6c |;. |if (!o.l|
|000019c0| 6f 67 66 64 29 20 0a 09 | 66 61 74 61 6c 28 22 46 |ogfd) ..|fatal("F|
|000019d0| 61 69 6c 65 64 20 74 6f | 20 6f 70 65 6e 20 6f 75 |ailed to| open ou|
|000019e0| 74 70 75 74 20 66 69 6c | 65 20 25 73 20 66 6f 72 |tput fil|e %s for|
|000019f0| 20 77 72 69 74 69 6e 67 | 22 2c 20 6f 70 74 61 72 | writing|", optar|
|00001a00| 67 29 3b 0a 20 20 20 20 | 7d 0a 20 20 20 20 62 72 |g);. |}. br|
|00001a10| 65 61 6b 3b 0a 20 20 63 | 61 73 65 20 27 50 27 3a |eak;. c|ase 'P':|
|00001a20| 20 0a 20 20 20 20 69 66 | 20 28 2a 6f 70 74 61 72 | . if| (*optar|
|00001a30| 67 20 3d 3d 20 27 5c 30 | 27 20 7c 7c 20 2a 6f 70 |g == '\0|' || *op|
|00001a40| 74 61 72 67 20 3d 3d 20 | 27 49 27 29 0a 20 20 20 |targ == |'I'). |
|00001a50| 20 20 20 6f 2e 70 69 6e | 67 74 79 70 65 20 7c 3d | o.pin|gtype |=|
|00001a60| 20 50 49 4e 47 54 59 50 | 45 5f 49 43 4d 50 3b 0a | PINGTYP|E_ICMP;.|
|00001a70| 20 20 20 20 65 6c 73 65 | 20 69 66 20 28 2a 6f 70 | else| if (*op|
|00001a80| 74 61 72 67 20 3d 3d 20 | 27 30 27 20 7c 7c 20 2a |targ == |'0' || *|
|00001a90| 6f 70 74 61 72 67 20 3d | 3d 20 27 4e 27 20 7c 7c |optarg =|= 'N' |||
|00001aa0| 20 2a 6f 70 74 61 72 67 | 20 3d 3d 20 27 44 27 29 | *optarg| == 'D')|
|00001ab0| 20 20 20 20 20 20 0a 20 | 20 20 20 20 20 6f 2e 70 | . | o.p|
|00001ac0| 69 6e 67 74 79 70 65 20 | 3d 20 50 49 4e 47 54 59 |ingtype |= PINGTY|
|00001ad0| 50 45 5f 4e 4f 4e 45 3b | 0a 20 20 20 20 65 6c 73 |PE_NONE;|. els|
|00001ae0| 65 20 69 66 20 28 2a 6f | 70 74 61 72 67 20 3d 3d |e if (*o|ptarg ==|
|00001af0| 20 27 53 27 29 20 7b 0a | 20 20 20 20 20 20 6f 2e | 'S') {.| o.|
|00001b00| 70 69 6e 67 74 79 70 65 | 20 7c 3d 20 28 50 49 4e |pingtype| |= (PIN|
|00001b10| 47 54 59 50 45 5f 54 43 | 50 7c 50 49 4e 47 54 59 |GTYPE_TC|P|PINGTY|
|00001b20| 50 45 5f 54 43 50 5f 55 | 53 45 5f 53 59 4e 29 3b |PE_TCP_U|SE_SYN);|
|00001b30| 0a 20 20 20 20 20 20 69 | 66 20 28 69 73 64 69 67 |. i|f (isdig|
|00001b40| 69 74 28 28 69 6e 74 29 | 20 2a 28 6f 70 74 61 72 |it((int)| *(optar|
|00001b50| 67 2b 31 29 29 29 20 7b | 20 20 20 20 20 20 0a 09 |g+1))) {| ..|
|00001b60| 6f 2e 74 63 70 5f 70 72 | 6f 62 65 5f 70 6f 72 74 |o.tcp_pr|obe_port|
|00001b70| 20 3d 20 61 74 6f 69 28 | 6f 70 74 61 72 67 2b 31 | = atoi(|optarg+1|
|00001b80| 29 3b 0a 09 66 70 72 69 | 6e 74 66 28 6f 2e 6e 6d |);..fpri|ntf(o.nm|
|00001b90| 61 70 5f 73 74 64 6f 75 | 74 2c 20 22 54 43 50 20 |ap_stdou|t, "TCP |
|00001ba0| 70 72 6f 62 65 20 70 6f | 72 74 20 69 73 20 25 68 |probe po|rt is %h|
|00001bb0| 75 5c 6e 22 2c 20 6f 2e | 74 63 70 5f 70 72 6f 62 |u\n", o.|tcp_prob|
|00001bc0| 65 5f 70 6f 72 74 29 3b | 0a 20 20 20 20 20 20 7d |e_port);|. }|
|00001bd0| 20 65 6c 73 65 20 69 66 | 20 28 6f 2e 76 65 72 62 | else if| (o.verb|
|00001be0| 6f 73 65 29 0a 09 66 70 | 72 69 6e 74 66 28 6f 2e |ose)..fp|rintf(o.|
|00001bf0| 6e 6d 61 70 5f 73 74 64 | 6f 75 74 2c 20 22 54 43 |nmap_std|out, "TC|
|00001c00| 50 20 70 72 6f 62 65 20 | 70 6f 72 74 20 69 73 20 |P probe |port is |
|00001c10| 25 68 75 5c 6e 22 2c 20 | 6f 2e 74 63 70 5f 70 72 |%hu\n", |o.tcp_pr|
|00001c20| 6f 62 65 5f 70 6f 72 74 | 29 3b 0a 20 20 20 20 7d |obe_port|);. }|
|00001c30| 0a 20 20 20 20 65 6c 73 | 65 20 69 66 20 28 2a 6f |. els|e if (*o|
|00001c40| 70 74 61 72 67 20 3d 3d | 20 27 54 27 20 7c 7c 20 |ptarg ==| 'T' || |
|00001c50| 2a 6f 70 74 61 72 67 20 | 3d 3d 20 27 41 27 29 20 |*optarg |== 'A') |
|00001c60| 7b 0a 20 20 20 20 20 20 | 6f 2e 70 69 6e 67 74 79 |{. |o.pingty|
|00001c70| 70 65 20 7c 3d 20 28 50 | 49 4e 47 54 59 50 45 5f |pe |= (P|INGTYPE_|
|00001c80| 54 43 50 7c 50 49 4e 47 | 54 59 50 45 5f 54 43 50 |TCP|PING|TYPE_TCP|
|00001c90| 5f 55 53 45 5f 41 43 4b | 29 3b 0a 20 20 20 20 20 |_USE_ACK|);. |
|00001ca0| 20 69 66 20 28 69 73 64 | 69 67 69 74 28 28 69 6e | if (isd|igit((in|
|00001cb0| 74 29 20 2a 28 6f 70 74 | 61 72 67 2b 31 29 29 29 |t) *(opt|arg+1)))|
|00001cc0| 20 7b 20 20 20 20 20 20 | 0a 09 6f 2e 74 63 70 5f | { |..o.tcp_|
|00001cd0| 70 72 6f 62 65 5f 70 6f | 72 74 20 3d 20 61 74 6f |probe_po|rt = ato|
|00001ce0| 69 28 6f 70 74 61 72 67 | 2b 31 29 3b 0a 09 66 70 |i(optarg|+1);..fp|
|00001cf0| 72 69 6e 74 66 28 6f 2e | 6e 6d 61 70 5f 73 74 64 |rintf(o.|nmap_std|
|00001d00| 6f 75 74 2c 20 22 54 43 | 50 20 70 72 6f 62 65 20 |out, "TC|P probe |
|00001d10| 70 6f 72 74 20 69 73 20 | 25 68 75 5c 6e 22 2c 20 |port is |%hu\n", |
|00001d20| 6f 2e 74 63 70 5f 70 72 | 6f 62 65 5f 70 6f 72 74 |o.tcp_pr|obe_port|
|00001d30| 29 3b 0a 20 20 20 20 20 | 20 7d 20 65 6c 73 65 20 |);. | } else |
|00001d40| 69 66 20 28 6f 2e 76 65 | 72 62 6f 73 65 29 0a 09 |if (o.ve|rbose)..|
|00001d50| 66 70 72 69 6e 74 66 28 | 6f 2e 6e 6d 61 70 5f 73 |fprintf(|o.nmap_s|
|00001d60| 74 64 6f 75 74 2c 20 22 | 54 43 50 20 70 72 6f 62 |tdout, "|TCP prob|
|00001d70| 65 20 70 6f 72 74 20 69 | 73 20 25 68 75 5c 6e 22 |e port i|s %hu\n"|
|00001d80| 2c 20 6f 2e 74 63 70 5f | 70 72 6f 62 65 5f 70 6f |, o.tcp_|probe_po|
|00001d90| 72 74 29 3b 0a 20 20 20 | 20 7d 0a 20 20 20 20 65 |rt);. | }. e|
|00001da0| 6c 73 65 20 69 66 20 28 | 2a 6f 70 74 61 72 67 20 |lse if (|*optarg |
|00001db0| 3d 3d 20 27 42 27 29 20 | 7b 0a 20 20 20 20 20 20 |== 'B') |{. |
|00001dc0| 6f 2e 70 69 6e 67 74 79 | 70 65 20 3d 20 28 50 49 |o.pingty|pe = (PI|
|00001dd0| 4e 47 54 59 50 45 5f 54 | 43 50 7c 50 49 4e 47 54 |NGTYPE_T|CP|PINGT|
|00001de0| 59 50 45 5f 54 43 50 5f | 55 53 45 5f 41 43 4b 7c |YPE_TCP_|USE_ACK||
|00001df0| 50 49 4e 47 54 59 50 45 | 5f 49 43 4d 50 29 3b 0a |PINGTYPE|_ICMP);.|
|00001e00| 20 20 20 20 20 20 69 66 | 20 28 69 73 64 69 67 69 | if| (isdigi|
|00001e10| 74 28 28 69 6e 74 29 20 | 2a 28 6f 70 74 61 72 67 |t((int) |*(optarg|
|00001e20| 2b 31 29 29 29 0a 09 6f | 2e 74 63 70 5f 70 72 6f |+1)))..o|.tcp_pro|
|00001e30| 62 65 5f 70 6f 72 74 20 | 3d 20 61 74 6f 69 28 6f |be_port |= atoi(o|
|00001e40| 70 74 61 72 67 2b 31 29 | 3b 0a 20 20 20 20 20 20 |ptarg+1)|;. |
|00001e50| 66 70 72 69 6e 74 66 28 | 6f 2e 6e 6d 61 70 5f 73 |fprintf(|o.nmap_s|
|00001e60| 74 64 6f 75 74 2c 20 22 | 54 43 50 20 70 72 6f 62 |tdout, "|TCP prob|
|00001e70| 65 20 70 6f 72 74 20 69 | 73 20 25 68 75 5c 6e 22 |e port i|s %hu\n"|
|00001e80| 2c 20 6f 2e 74 63 70 5f | 70 72 6f 62 65 5f 70 6f |, o.tcp_|probe_po|
|00001e90| 72 74 29 3b 0a 20 20 20 | 20 7d 0a 20 20 20 20 65 |rt);. | }. e|
|00001ea0| 6c 73 65 20 7b 66 61 74 | 61 6c 28 22 49 6c 6c 65 |lse {fat|al("Ille|
|00001eb0| 67 61 6c 20 41 72 67 75 | 6d 65 6e 74 20 74 6f 20 |gal Argu|ment to |
|00001ec0| 2d 50 2c 20 75 73 65 20 | 2d 50 30 2c 20 2d 50 49 |-P, use |-P0, -PI|
|00001ed0| 2c 20 2d 50 54 2c 20 6f | 72 20 2d 50 54 38 30 20 |, -PT, o|r -PT80 |
|00001ee0| 28 6f 72 20 77 68 61 74 | 65 76 65 72 20 6e 75 6d |(or what|ever num|
|00001ef0| 62 65 72 20 79 6f 75 20 | 77 61 6e 74 20 66 6f 72 |ber you |want for|
|00001f00| 20 74 68 65 20 54 43 50 | 20 70 72 6f 62 65 20 64 | the TCP| probe d|
|00001f10| 65 73 74 69 6e 61 74 69 | 6f 6e 20 70 6f 72 74 29 |estinati|on port)|
|00001f20| 22 29 3b 20 7d 0a 20 20 | 20 20 62 72 65 61 6b 3b |"); }. | break;|
|00001f30| 0a 20 20 63 61 73 65 20 | 27 70 27 3a 20 0a 20 20 |. case |'p': . |
|00001f40| 20 20 69 66 20 28 70 6f | 72 74 73 29 0a 20 20 20 | if (po|rts). |
|00001f50| 20 20 20 66 61 74 61 6c | 28 22 4f 6e 6c 79 20 31 | fatal|("Only 1|
|00001f60| 20 2d 70 20 6f 70 74 69 | 6f 6e 20 61 6c 6c 6f 77 | -p opti|on allow|
|00001f70| 65 64 2c 20 73 65 70 61 | 72 61 74 65 20 6d 75 6c |ed, sepa|rate mul|
|00001f80| 74 69 70 6c 65 20 72 61 | 6e 67 65 73 20 77 69 74 |tiple ra|nges wit|
|00001f90| 68 20 63 6f 6d 6d 61 73 | 2e 22 29 3b 0a 20 20 20 |h commas|.");. |
|00001fa0| 20 70 6f 72 74 73 20 3d | 20 67 65 74 70 74 73 28 | ports =| getpts(|
|00001fb0| 6f 70 74 61 72 67 29 3b | 20 62 72 65 61 6b 3b 0a |optarg);| break;.|
|00001fc0| 20 20 20 20 69 66 20 28 | 21 70 6f 72 74 73 29 0a | if (|!ports).|
|00001fd0| 20 20 20 20 20 20 66 61 | 74 61 6c 28 22 59 6f 75 | fa|tal("You|
|00001fe0| 72 20 70 6f 72 74 20 73 | 70 65 63 69 66 69 63 61 |r port s|pecifica|
|00001ff0| 74 69 6f 6e 20 73 74 72 | 69 6e 67 20 69 73 20 6e |tion str|ing is n|
|00002000| 6f 74 20 70 61 72 73 65 | 61 62 6c 65 22 29 3b 0a |ot parse|able");.|
|00002010| 20 20 63 61 73 65 20 27 | 71 27 3a 20 71 75 61 73 | case '|q': quas|
|00002020| 68 61 72 67 76 2b 2b 3b | 20 62 72 65 61 6b 3b 0a |hargv++;| break;.|
|00002030| 20 20 63 61 73 65 20 27 | 52 27 3a 20 72 65 73 6f | case '|R': reso|
|00002040| 6c 76 65 5f 61 6c 6c 2b | 2b 3b 20 62 72 65 61 6b |lve_all+|+; break|
|00002050| 3b 0a 20 20 63 61 73 65 | 20 27 72 27 3a 20 0a 20 |;. case| 'r': . |
|00002060| 20 20 20 72 61 6e 64 6f | 6d 69 7a 65 20 3d 20 30 | rando|mize = 0|
|00002070| 3b 0a 20 20 20 20 65 72 | 72 6f 72 28 22 57 61 72 |;. er|ror("War|
|00002080| 6e 69 6e 67 3a 20 52 61 | 6e 64 6f 6d 69 7a 65 20 |ning: Ra|ndomize |
|00002090| 73 79 6e 74 61 78 20 68 | 61 73 20 62 65 65 6e 20 |syntax h|as been |
|000020a0| 63 68 61 6e 67 65 64 2c | 20 2d 72 20 6e 6f 77 20 |changed,| -r now |
|000020b0| 72 65 71 75 65 73 74 73 | 20 74 68 61 74 20 70 6f |requests| that po|
|000020c0| 72 74 73 20 4e 4f 54 20 | 62 65 20 72 61 6e 64 6f |rts NOT |be rando|
|000020d0| 6d 69 7a 65 64 22 29 3b | 0a 20 20 20 20 62 72 65 |mized");|. bre|
|000020e0| 61 6b 3b 0a 20 20 63 61 | 73 65 20 27 53 27 3a 20 |ak;. ca|se 'S': |
|000020f0| 0a 20 20 20 20 69 66 20 | 28 6f 2e 73 70 6f 6f 66 |. if |(o.spoof|
|00002100| 73 6f 75 72 63 65 29 0a | 20 20 20 20 20 20 66 61 |source).| fa|
|00002110| 74 61 6c 28 22 59 6f 75 | 20 63 61 6e 20 6f 6e 6c |tal("You| can onl|
|00002120| 79 20 75 73 65 20 74 68 | 65 20 73 6f 75 72 63 65 |y use th|e source|
|00002130| 20 6f 70 74 69 6f 6e 20 | 6f 6e 63 65 21 20 20 55 | option |once! U|
|00002140| 73 65 20 2d 44 20 3c 64 | 65 63 6f 79 31 3e 20 2d |se -D <d|ecoy1> -|
|00002150| 44 20 3c 64 65 63 6f 79 | 32 3e 20 65 74 63 2e 20 |D <decoy|2> etc. |
|00002160| 66 6f 72 20 64 65 63 6f | 79 73 5c 6e 22 29 3b 0a |for deco|ys\n");.|
|00002170| 20 20 20 20 6f 2e 73 6f | 75 72 63 65 20 3d 20 73 | o.so|urce = s|
|00002180| 61 66 65 5f 6d 61 6c 6c | 6f 63 28 73 69 7a 65 6f |afe_mall|oc(sizeo|
|00002190| 66 28 73 74 72 75 63 74 | 20 69 6e 5f 61 64 64 72 |f(struct| in_addr|
|000021a0| 29 29 3b 0a 20 20 20 20 | 6f 2e 73 70 6f 6f 66 73 |));. |o.spoofs|
|000021b0| 6f 75 72 63 65 20 3d 20 | 31 3b 0a 20 20 20 20 69 |ource = |1;. i|
|000021c0| 66 20 28 21 72 65 73 6f | 6c 76 65 28 6f 70 74 61 |f (!reso|lve(opta|
|000021d0| 72 67 2c 20 6f 2e 73 6f | 75 72 63 65 29 29 0a 20 |rg, o.so|urce)). |
|000021e0| 20 20 20 20 20 66 61 74 | 61 6c 28 22 46 61 69 6c | fat|al("Fail|
|000021f0| 65 64 20 74 6f 20 72 65 | 73 6f 6c 76 65 20 73 6f |ed to re|solve so|
|00002200| 75 72 63 65 20 61 64 64 | 72 65 73 73 2c 20 74 72 |urce add|ress, tr|
|00002210| 79 20 64 6f 74 74 65 64 | 20 64 65 63 69 6d 61 6c |y dotted| decimal|
|00002220| 20 49 50 20 61 64 64 72 | 65 73 73 5c 6e 22 29 3b | IP addr|ess\n");|
|00002230| 0a 20 20 20 20 62 72 65 | 61 6b 3b 0a 20 20 63 61 |. bre|ak;. ca|
|00002240| 73 65 20 27 73 27 3a 20 | 0a 20 20 20 20 69 66 20 |se 's': |. if |
|00002250| 28 21 2a 6f 70 74 61 72 | 67 29 20 7b 0a 20 20 20 |(!*optar|g) {. |
|00002260| 20 20 20 66 70 72 69 6e | 74 66 28 73 74 64 65 72 | fprin|tf(stder|
|00002270| 72 2c 20 22 41 6e 20 6f | 70 74 69 6f 6e 20 69 73 |r, "An o|ption is|
|00002280| 20 72 65 71 75 69 72 65 | 64 20 66 6f 72 20 2d 73 | require|d for -s|
|00002290| 2c 20 6d 6f 73 74 20 63 | 6f 6d 6d 6f 6e 20 61 72 |, most c|ommon ar|
|000022a0| 65 20 2d 73 54 20 28 74 | 63 70 20 73 63 61 6e 29 |e -sT (t|cp scan)|
|000022b0| 2c 20 2d 73 53 20 28 53 | 59 4e 20 73 63 61 6e 29 |, -sS (S|YN scan)|
|000022c0| 2c 20 2d 73 46 20 28 46 | 49 4e 20 73 63 61 6e 29 |, -sF (F|IN scan)|
|000022d0| 2c 20 2d 73 55 20 28 55 | 44 50 20 73 63 61 6e 29 |, -sU (U|DP scan)|
|000022e0| 20 61 6e 64 20 2d 73 50 | 20 28 50 69 6e 67 20 73 | and -sP| (Ping s|
|000022f0| 63 61 6e 29 22 29 3b 0a | 20 20 20 20 20 20 70 72 |can)");.| pr|
|00002300| 69 6e 74 75 73 61 67 65 | 28 61 72 67 76 5b 30 5d |intusage|(argv[0]|
|00002310| 29 3b 0a 20 20 20 20 7d | 0a 20 20 20 20 20 20 70 |);. }|. p|
|00002320| 20 3d 20 6f 70 74 61 72 | 67 3b 0a 20 20 20 20 20 | = optar|g;. |
|00002330| 20 77 68 69 6c 65 28 2a | 70 29 20 7b 0a 09 73 77 | while(*|p) {..sw|
|00002340| 69 74 63 68 28 2a 70 29 | 20 7b 0a 09 63 61 73 65 |itch(*p)| {..case|
|00002350| 20 27 42 27 3a 20 20 66 | 61 74 61 6c 28 22 4e 6f | 'B': f|atal("No|
|00002360| 20 73 63 61 6e 20 74 79 | 70 65 20 27 42 27 2c 20 | scan ty|pe 'B', |
|00002370| 64 69 64 20 79 6f 75 20 | 6d 65 61 6e 20 62 6f 75 |did you |mean bou|
|00002380| 6e 63 65 20 73 63 61 6e | 20 28 2d 62 29 3f 22 29 |nce scan| (-b)?")|
|00002390| 3b 0a 09 20 20 62 72 65 | 61 6b 3b 0a 09 63 61 73 |;.. bre|ak;..cas|
|000023a0| 65 20 27 46 27 3a 20 20 | 6f 2e 66 69 6e 73 63 61 |e 'F': |o.finsca|
|000023b0| 6e 20 3d 20 31 3b 20 62 | 72 65 61 6b 3b 0a 09 63 |n = 1; b|reak;..c|
|000023c0| 61 73 65 20 27 4d 27 3a | 20 20 6f 2e 6d 61 69 6d |ase 'M':| o.maim|
|000023d0| 6f 6e 73 63 61 6e 20 3d | 20 31 3b 20 62 72 65 61 |onscan =| 1; brea|
|000023e0| 6b 3b 0a 09 63 61 73 65 | 20 27 4e 27 3a 20 20 6f |k;..case| 'N': o|
|000023f0| 2e 6e 75 6c 6c 73 63 61 | 6e 20 3d 20 31 3b 20 62 |.nullsca|n = 1; b|
|00002400| 72 65 61 6b 3b 0a 09 63 | 61 73 65 20 27 50 27 3a |reak;..c|ase 'P':|
|00002410| 20 20 6f 2e 70 69 6e 67 | 73 63 61 6e 20 3d 20 31 | o.ping|scan = 1|
|00002420| 3b 20 62 72 65 61 6b 3b | 0a 09 63 61 73 65 20 27 |; break;|..case '|
|00002430| 53 27 3a 20 20 6f 2e 73 | 79 6e 73 63 61 6e 20 3d |S': o.s|ynscan =|
|00002440| 20 31 3b 20 62 72 65 61 | 6b 3b 0a 09 63 61 73 65 | 1; brea|k;..case|
|00002450| 20 27 54 27 3a 20 20 6f | 2e 63 6f 6e 6e 65 63 74 | 'T': o|.connect|
|00002460| 73 63 61 6e 20 3d 20 31 | 3b 20 62 72 65 61 6b 3b |scan = 1|; break;|
|00002470| 0a 09 63 61 73 65 20 27 | 55 27 3a 20 20 0a 09 20 |..case '|U': .. |
|00002480| 20 66 70 72 69 6e 74 66 | 28 6f 2e 6e 6d 61 70 5f | fprintf|(o.nmap_|
|00002490| 73 74 64 6f 75 74 2c 20 | 22 57 41 52 4e 49 4e 47 |stdout, |"WARNING|
|000024a0| 3a 20 20 2d 73 55 20 69 | 73 20 6e 6f 77 20 55 44 |: -sU i|s now UD|
|000024b0| 50 20 73 63 61 6e 20 2d | 2d 20 66 6f 72 20 54 43 |P scan -|- for TC|
|000024c0| 50 20 46 49 4e 20 73 63 | 61 6e 20 75 73 65 20 2d |P FIN sc|an use -|
|000024d0| 73 46 5c 6e 22 29 3b 0a | 09 20 20 6f 2e 75 64 70 |sF\n");.|. o.udp|
|000024e0| 73 63 61 6e 2b 2b 3b 0a | 09 20 20 62 72 65 61 6b |scan++;.|. break|
|000024f0| 3b 0a 09 63 61 73 65 20 | 27 58 27 3a 20 20 6f 2e |;..case |'X': o.|
|00002500| 78 6d 61 73 73 63 61 6e | 2b 2b 3b 62 72 65 61 6b |xmasscan|++;break|
|00002510| 3b 0a 09 64 65 66 61 75 | 6c 74 3a 20 20 65 72 72 |;..defau|lt: err|
|00002520| 6f 72 28 22 53 63 61 6e | 74 79 70 65 20 25 63 20 |or("Scan|type %c |
|00002530| 6e 6f 74 20 73 75 70 70 | 6f 72 74 65 64 5c 6e 22 |not supp|orted\n"|
|00002540| 2c 2a 70 29 3b 20 70 72 | 69 6e 74 75 73 61 67 65 |,*p); pr|intusage|
|00002550| 28 61 72 67 76 5b 30 5d | 29 3b 20 62 72 65 61 6b |(argv[0]|); break|
|00002560| 3b 0a 09 7d 0a 09 70 2b | 2b 3b 0a 20 20 20 20 20 |;..}..p+|+;. |
|00002570| 20 7d 0a 20 20 20 20 20 | 20 62 72 65 61 6b 3b 0a | }. | break;.|
|00002580| 20 20 63 61 73 65 20 27 | 54 27 3a 20 6f 2e 70 74 | case '|T': o.pt|
|00002590| 69 6d 65 20 3d 20 61 74 | 6f 69 28 6f 70 74 61 72 |ime = at|oi(optar|
|000025a0| 67 29 3b 20 62 72 65 61 | 6b 3b 0a 20 20 63 61 73 |g); brea|k;. cas|
|000025b0| 65 20 27 56 27 3a 20 0a | 20 20 20 20 70 72 69 6e |e 'V': .| prin|
|000025c0| 74 66 28 22 5c 6e 6e 6d | 61 70 20 56 2e 20 25 73 |tf("\nnm|ap V. %s|
|000025d0| 20 62 79 20 46 79 6f 64 | 6f 72 20 28 66 79 6f 64 | by Fyod|or (fyod|
|000025e0| 6f 72 40 64 68 70 2e 63 | 6f 6d 2c 20 77 77 77 2e |or@dhp.c|om, www.|
|000025f0| 69 6e 73 65 63 75 72 65 | 2e 6f 72 67 2f 6e 6d 61 |insecure|.org/nma|
|00002600| 70 2f 29 5c 6e 22 2c 20 | 56 45 52 53 49 4f 4e 29 |p/)\n", |VERSION)|
|00002610| 3b 20 0a 20 20 20 20 65 | 78 69 74 28 30 29 3b 0a |; . e|xit(0);.|
|00002620| 20 20 20 20 62 72 65 61 | 6b 3b 0a 20 20 63 61 73 | brea|k;. cas|
|00002630| 65 20 27 76 27 3a 20 6f | 2e 76 65 72 62 6f 73 65 |e 'v': o|.verbose|
|00002640| 2b 2b 3b 20 62 72 65 61 | 6b 3b 0a 20 20 7d 0a 7d |++; brea|k;. }.}|
|00002650| 0a 0a 20 66 70 72 69 6e | 74 66 28 6f 2e 6e 6d 61 |.. fprin|tf(o.nma|
|00002660| 70 5f 73 74 64 6f 75 74 | 2c 20 22 5c 6e 53 74 61 |p_stdout|, "\nSta|
|00002670| 72 74 69 6e 67 20 6e 6d | 61 70 20 56 2e 20 25 73 |rting nm|ap V. %s|
|00002680| 20 62 79 20 46 79 6f 64 | 6f 72 20 28 66 79 6f 64 | by Fyod|or (fyod|
|00002690| 6f 72 40 64 68 70 2e 63 | 6f 6d 2c 20 77 77 77 2e |or@dhp.c|om, www.|
|000026a0| 69 6e 73 65 63 75 72 65 | 2e 6f 72 67 2f 6e 6d 61 |insecure|.org/nma|
|000026b0| 70 2f 29 5c 6e 22 2c 20 | 56 45 52 53 49 4f 4e 29 |p/)\n", |VERSION)|
|000026c0| 3b 0a 0a 69 66 20 28 6f | 2e 70 69 6e 67 74 79 70 |;..if (o|.pingtyp|
|000026d0| 65 20 3d 3d 20 50 49 4e | 47 54 59 50 45 5f 55 4e |e == PIN|GTYPE_UN|
|000026e0| 4b 4e 4f 57 4e 29 20 7b | 0a 20 20 69 66 20 28 6f |KNOWN) {|. if (o|
|000026f0| 2e 69 73 72 30 30 74 29 | 20 6f 2e 70 69 6e 67 74 |.isr00t)| o.pingt|
|00002700| 79 70 65 20 3d 20 50 49 | 4e 47 54 59 50 45 5f 54 |ype = PI|NGTYPE_T|
|00002710| 43 50 7c 50 49 4e 47 54 | 59 50 45 5f 54 43 50 5f |CP|PINGT|YPE_TCP_|
|00002720| 55 53 45 5f 41 43 4b 7c | 50 49 4e 47 54 59 50 45 |USE_ACK||PINGTYPE|
|00002730| 5f 49 43 4d 50 3b 0a 20 | 20 65 6c 73 65 20 6f 2e |_ICMP;. | else o.|
|00002740| 70 69 6e 67 74 79 70 65 | 20 3d 20 50 49 4e 47 54 |pingtype| = PINGT|
|00002750| 59 50 45 5f 54 43 50 3b | 0a 7d 0a 0a 0a 2f 2a 20 |YPE_TCP;|.}.../* |
|00002760| 4e 6f 77 20 77 65 20 63 | 68 65 63 6b 20 74 68 65 |Now we c|heck the|
|00002770| 20 6f 70 74 69 6f 6e 20 | 73 61 6e 69 74 79 20 2a | option |sanity *|
|00002780| 2f 0a 2f 2a 20 49 6e 73 | 75 72 65 20 74 68 61 74 |/./* Ins|ure that|
|00002790| 20 61 74 20 6c 65 61 73 | 74 20 6f 6e 65 20 73 63 | at leas|t one sc|
|000027a0| 61 6e 74 79 70 65 20 69 | 73 20 73 65 6c 65 63 74 |antype i|s select|
|000027b0| 65 64 20 2a 2f 0a 69 66 | 20 28 21 6f 2e 63 6f 6e |ed */.if| (!o.con|
|000027c0| 6e 65 63 74 73 63 61 6e | 20 26 26 20 21 6f 2e 75 |nectscan| && !o.u|
|000027d0| 64 70 73 63 61 6e 20 26 | 26 20 21 6f 2e 73 79 6e |dpscan &|& !o.syn|
|000027e0| 73 63 61 6e 20 26 26 20 | 21 6f 2e 66 69 6e 73 63 |scan && |!o.finsc|
|000027f0| 61 6e 20 26 26 20 21 6f | 2e 6d 61 69 6d 6f 6e 73 |an && !o|.maimons|
|00002800| 63 61 6e 20 26 26 20 20 | 21 6f 2e 6e 75 6c 6c 73 |can && |!o.nulls|
|00002810| 63 61 6e 20 26 26 20 21 | 6f 2e 78 6d 61 73 73 63 |can && !|o.xmassc|
|00002820| 61 6e 20 26 26 20 21 6f | 2e 62 6f 75 6e 63 65 73 |an && !o|.bounces|
|00002830| 63 61 6e 20 26 26 20 21 | 6f 2e 70 69 6e 67 73 63 |can && !|o.pingsc|
|00002840| 61 6e 29 20 7b 0a 20 20 | 6f 2e 63 6f 6e 6e 65 63 |an) {. |o.connec|
|00002850| 74 73 63 61 6e 2b 2b 3b | 0a 20 20 69 66 20 28 6f |tscan++;|. if (o|
|00002860| 2e 76 65 72 62 6f 73 65 | 29 20 65 72 72 6f 72 28 |.verbose|) error(|
|00002870| 22 4e 6f 20 73 63 61 6e | 74 79 70 65 20 73 70 65 |"No scan|type spe|
|00002880| 63 69 66 69 65 64 2c 20 | 61 73 73 75 6d 69 6e 67 |cified, |assuming|
|00002890| 20 76 61 6e 69 6c 6c 61 | 20 74 63 70 20 63 6f 6e | vanilla| tcp con|
|000028a0| 6e 65 63 74 28 29 20 73 | 63 61 6e 2e 20 55 73 65 |nect() s|can. Use|
|000028b0| 20 2d 73 50 20 69 66 20 | 79 6f 75 20 72 65 61 6c | -sP if |you real|
|000028c0| 6c 79 20 64 6f 6e 27 74 | 20 77 61 6e 74 20 74 6f |ly don't| want to|
|000028d0| 20 70 6f 72 74 73 63 61 | 6e 20 28 61 6e 64 20 6a | portsca|n (and j|
|000028e0| 75 73 74 20 77 61 6e 74 | 20 74 6f 20 73 65 65 20 |ust want| to see |
|000028f0| 77 68 61 74 20 68 6f 73 | 74 73 20 61 72 65 20 75 |what hos|ts are u|
|00002900| 70 29 2e 22 29 3b 0a 7d | 0a 0a 69 66 20 28 6f 2e |p).");.}|..if (o.|
|00002910| 70 69 6e 67 74 79 70 65 | 20 21 3d 20 50 49 4e 47 |pingtype| != PING|
|00002920| 54 59 50 45 5f 4e 4f 4e | 45 20 26 26 20 6f 2e 73 |TYPE_NON|E && o.s|
|00002930| 70 6f 6f 66 73 6f 75 72 | 63 65 29 20 7b 0a 20 20 |poofsour|ce) {. |
|00002940| 65 72 72 6f 72 28 22 57 | 41 52 4e 49 4e 47 3a 20 |error("W|ARNING: |
|00002950| 20 49 66 20 2d 53 20 69 | 73 20 62 65 69 6e 67 20 | If -S i|s being |
|00002960| 75 73 65 64 20 74 6f 20 | 66 61 6b 65 20 79 6f 75 |used to |fake you|
|00002970| 72 20 73 6f 75 72 63 65 | 20 61 64 64 72 65 73 73 |r source| address|
|00002980| 2c 20 79 6f 75 20 6d 61 | 79 20 61 6c 73 6f 20 68 |, you ma|y also h|
|00002990| 61 76 65 20 74 6f 20 75 | 73 65 20 2d 65 20 3c 69 |ave to u|se -e <i|
|000029a0| 66 61 63 65 3e 20 61 6e | 64 20 2d 50 30 20 2e 20 |face> an|d -P0 . |
|000029b0| 20 49 66 20 79 6f 75 20 | 61 72 65 20 75 73 69 6e | If you |are usin|
|000029c0| 67 20 69 74 20 74 6f 20 | 73 70 65 63 69 66 79 20 |g it to |specify |
|000029d0| 79 6f 75 72 20 72 65 61 | 6c 20 73 6f 75 72 63 65 |your rea|l source|
|000029e0| 20 61 64 64 72 65 73 73 | 2c 20 79 6f 75 20 63 61 | address|, you ca|
|000029f0| 6e 20 69 67 6e 6f 72 65 | 20 74 68 69 73 20 77 61 |n ignore| this wa|
|00002a00| 72 6e 69 6e 67 2e 22 29 | 3b 0a 7d 0a 0a 69 66 20 |rning.")|;.}..if |
|00002a10| 28 6f 2e 63 6f 6e 6e 65 | 63 74 73 63 61 6e 20 26 |(o.conne|ctscan &|
|00002a20| 26 20 6f 2e 73 70 6f 6f | 66 73 6f 75 72 63 65 29 |& o.spoo|fsource)|
|00002a30| 20 7b 0a 20 20 65 72 72 | 6f 72 28 22 57 41 52 4e | {. err|or("WARN|
|00002a40| 49 4e 47 3a 20 20 2d 53 | 20 77 69 6c 6c 20 6e 6f |ING: -S| will no|
|00002a50| 74 20 61 66 66 65 63 74 | 20 74 68 65 20 73 6f 75 |t affect| the sou|
|00002a60| 72 63 65 20 61 64 64 72 | 65 73 73 20 75 73 65 64 |rce addr|ess used|
|00002a70| 20 69 6e 20 61 20 63 6f | 6e 6e 65 63 74 28 29 20 | in a co|nnect() |
|00002a80| 73 63 61 6e 2e 20 20 55 | 73 65 20 2d 73 53 20 6f |scan. U|se -sS o|
|00002a90| 72 20 61 6e 6f 74 68 65 | 72 20 72 61 77 20 73 63 |r anothe|r raw sc|
|00002aa0| 61 6e 20 69 66 20 79 6f | 75 20 77 61 6e 74 20 74 |an if yo|u want t|
|00002ab0| 6f 20 75 73 65 20 74 68 | 65 20 73 70 65 63 69 66 |o use th|e specif|
|00002ac0| 69 65 64 20 73 6f 75 72 | 63 65 20 61 64 64 72 65 |ied sour|ce addre|
|00002ad0| 73 73 20 66 6f 72 20 74 | 68 65 20 70 6f 72 74 20 |ss for t|he port |
|00002ae0| 73 63 61 6e 6e 69 6e 67 | 20 73 74 61 67 65 20 6f |scanning| stage o|
|00002af0| 66 20 6e 6d 61 70 22 29 | 3b 0a 7d 0a 0a 69 66 20 |f nmap")|;.}..if |
|00002b00| 28 66 61 73 74 73 63 61 | 6e 20 26 26 20 70 6f 72 |(fastsca|n && por|
|00002b10| 74 73 29 20 7b 0a 20 20 | 66 61 74 61 6c 28 22 59 |ts) {. |fatal("Y|
|00002b20| 6f 75 20 63 61 6e 20 73 | 70 65 63 69 66 79 20 66 |ou can s|pecify f|
|00002b30| 61 73 74 20 73 63 61 6e | 20 28 2d 46 29 20 6f 72 |ast scan| (-F) or|
|00002b40| 20 65 78 70 6c 69 63 69 | 74 6c 79 20 73 65 6c 65 | explici|tly sele|
|00002b50| 63 74 20 69 6e 64 69 76 | 69 64 75 61 6c 20 70 6f |ct indiv|idual po|
|00002b60| 72 74 73 20 28 2d 70 29 | 2c 20 62 75 74 20 6e 6f |rts (-p)|, but no|
|00002b70| 74 20 62 6f 74 68 22 29 | 3b 0a 7d 20 65 6c 73 65 |t both")|;.} else|
|00002b80| 20 69 66 20 28 66 61 73 | 74 73 63 61 6e 29 20 7b | if (fas|tscan) {|
|00002b90| 0a 20 20 70 6f 72 74 73 | 20 3d 20 67 65 74 66 61 |. ports| = getfa|
|00002ba0| 73 74 70 6f 72 74 73 28 | 6f 2e 73 79 6e 73 63 61 |stports(|o.synsca|
|00002bb0| 6e 7c 6f 2e 63 6f 6e 6e | 65 63 74 73 63 61 6e 7c |n|o.conn|ectscan||
|00002bc0| 6f 2e 66 72 61 67 73 63 | 61 6e 7c 6f 2e 66 69 6e |o.fragsc|an|o.fin|
|00002bd0| 73 63 61 6e 7c 6f 2e 6d | 61 69 6d 6f 6e 73 63 61 |scan|o.m|aimonsca|
|00002be0| 6e 7c 6f 2e 62 6f 75 6e | 63 65 73 63 61 6e 7c 6f |n|o.boun|cescan|o|
|00002bf0| 2e 6e 75 6c 6c 73 63 61 | 6e 7c 6f 2e 78 6d 61 73 |.nullsca|n|o.xmas|
|00002c00| 73 63 61 6e 2c 6f 2e 75 | 64 70 73 63 61 6e 29 3b |scan,o.u|dpscan);|
|00002c10| 0a 7d 0a 0a 69 66 20 28 | 6f 2e 70 69 6e 67 73 63 |.}..if (|o.pingsc|
|00002c20| 61 6e 20 26 26 20 70 6f | 72 74 73 29 20 7b 0a 20 |an && po|rts) {. |
|00002c30| 20 66 61 74 61 6c 28 22 | 59 6f 75 20 63 61 6e 6e | fatal("|You cann|
|00002c40| 6f 74 20 75 73 65 20 2d | 46 20 28 66 61 73 74 20 |ot use -|F (fast |
|00002c50| 73 63 61 6e 29 20 6f 72 | 20 2d 70 20 28 65 78 70 |scan) or| -p (exp|
|00002c60| 6c 69 63 69 74 20 70 6f | 72 74 20 73 65 6c 65 63 |licit po|rt selec|
|00002c70| 74 69 6f 6e 29 20 77 69 | 74 68 20 50 49 4e 47 20 |tion) wi|th PING |
|00002c80| 73 63 61 6e 22 29 3b 0a | 7d 0a 0a 69 66 20 28 6f |scan");.|}..if (o|
|00002c90| 2e 70 69 6e 67 73 63 61 | 6e 20 26 26 20 66 61 73 |.pingsca|n && fas|
|00002ca0| 74 73 63 61 6e 29 20 7b | 0a 20 20 66 61 74 61 6c |tscan) {|. fatal|
|00002cb0| 28 22 54 68 65 20 66 61 | 73 74 20 73 63 61 6e 20 |("The fa|st scan |
|00002cc0| 28 2d 46 29 20 69 73 20 | 69 6e 63 6f 6d 70 61 74 |(-F) is |incompat|
|00002cd0| 69 62 6c 65 20 77 69 74 | 68 20 70 69 6e 67 20 73 |ible wit|h ping s|
|00002ce0| 63 61 6e 22 29 3b 0a 7d | 0a 0a 69 66 20 28 21 70 |can");.}|..if (!p|
|00002cf0| 6f 72 74 73 29 20 7b 0a | 20 20 70 6f 72 74 73 20 |orts) {.| ports |
|00002d00| 3d 20 67 65 74 64 65 66 | 61 75 6c 74 70 6f 72 74 |= getdef|aultport|
|00002d10| 73 28 6f 2e 73 79 6e 73 | 63 61 6e 7c 6f 2e 63 6f |s(o.syns|can|o.co|
|00002d20| 6e 6e 65 63 74 73 63 61 | 6e 7c 6f 2e 66 72 61 67 |nnectsca|n|o.frag|
|00002d30| 73 63 61 6e 7c 6f 2e 66 | 69 6e 73 63 61 6e 7c 0a |scan|o.f|inscan|.|
|00002d40| 09 09 09 20 20 6f 2e 6d | 61 69 6d 6f 6e 73 63 61 |... o.m|aimonsca|
|00002d50| 6e 7c 6f 2e 62 6f 75 6e | 63 65 73 63 61 6e 7c 6f |n|o.boun|cescan|o|
|00002d60| 2e 6e 75 6c 6c 73 63 61 | 6e 7c 6f 2e 78 6d 61 73 |.nullsca|n|o.xmas|
|00002d70| 73 63 61 6e 2c 0a 09 09 | 09 20 20 6f 2e 75 64 70 |scan,...|. o.udp|
|00002d80| 73 63 61 6e 29 3b 0a 7d | 0a 0a 2f 2a 20 44 65 66 |scan);.}|../* Def|
|00002d90| 61 75 6c 74 20 64 65 73 | 74 20 70 6f 72 74 20 66 |ault des|t port f|
|00002da0| 6f 72 20 74 63 70 20 70 | 72 6f 62 65 20 2a 2f 0a |or tcp p|robe */.|
|00002db0| 69 66 20 28 21 6f 2e 74 | 63 70 5f 70 72 6f 62 65 |if (!o.t|cp_probe|
|00002dc0| 5f 70 6f 72 74 29 20 6f | 2e 74 63 70 5f 70 72 6f |_port) o|.tcp_pro|
|00002dd0| 62 65 5f 70 6f 72 74 20 | 3d 20 38 30 3b 0a 0a 0a |be_port |= 80;...|
|00002de0| 69 66 20 28 6f 2e 70 69 | 6e 67 73 63 61 6e 20 26 |if (o.pi|ngscan &|
|00002df0| 26 20 28 6f 2e 63 6f 6e | 6e 65 63 74 73 63 61 6e |& (o.con|nectscan|
|00002e00| 20 7c 7c 20 6f 2e 75 64 | 70 73 63 61 6e 20 7c 7c | || o.ud|pscan |||
|00002e10| 20 6f 2e 73 79 6e 73 63 | 61 6e 20 7c 7c 20 6f 2e | o.synsc|an || o.|
|00002e20| 66 69 6e 73 63 61 6e 20 | 7c 7c 20 6f 2e 6d 61 69 |finscan ||| o.mai|
|00002e30| 6d 6f 6e 73 63 61 6e 20 | 7c 7c 20 20 6f 2e 6e 75 |monscan ||| o.nu|
|00002e40| 6c 6c 73 63 61 6e 20 7c | 7c 20 6f 2e 78 6d 61 73 |llscan ||| o.xmas|
|00002e50| 73 63 61 6e 20 7c 7c 20 | 6f 2e 62 6f 75 6e 63 65 |scan || |o.bounce|
|00002e60| 73 63 61 6e 29 29 20 7b | 0a 20 20 66 61 74 61 6c |scan)) {|. fatal|
|00002e70| 28 22 50 69 6e 67 20 73 | 63 61 6e 20 69 73 20 6e |("Ping s|can is n|
|00002e80| 6f 74 20 76 61 6c 69 64 | 20 77 69 74 68 20 61 6e |ot valid| with an|
|00002e90| 79 20 6f 74 68 65 72 20 | 73 63 61 6e 20 74 79 70 |y other |scan typ|
|00002ea0| 65 73 20 28 74 68 65 20 | 6f 74 68 65 72 20 6f 6e |es (the |other on|
|00002eb0| 65 73 20 61 6c 6c 20 69 | 6e 63 6c 75 64 65 20 61 |es all i|nclude a|
|00002ec0| 20 70 69 6e 67 20 73 63 | 61 6e 22 29 3b 0a 7d 0a | ping sc|an");.}.|
|00002ed0| 0a 2f 2a 20 57 65 20 73 | 74 61 72 74 20 77 69 74 |./* We s|tart wit|
|00002ee0| 68 20 73 74 75 66 66 20 | 75 73 65 72 73 20 73 68 |h stuff |users sh|
|00002ef0| 6f 75 6c 64 20 6e 6f 74 | 20 64 6f 20 69 66 20 74 |ould not| do if t|
|00002f00| 68 65 79 20 61 72 65 20 | 6e 6f 74 20 72 6f 6f 74 |hey are |not root|
|00002f10| 20 2a 2f 0a 69 66 20 28 | 21 6f 2e 69 73 72 30 30 | */.if (|!o.isr00|
|00002f20| 74 29 20 7b 0a 0a 20 20 | 69 66 20 28 6f 2e 70 69 |t) {.. |if (o.pi|
|00002f30| 6e 67 74 79 70 65 20 26 | 20 50 49 4e 47 54 59 50 |ngtype &| PINGTYP|
|00002f40| 45 5f 49 43 4d 50 29 20 | 7b 0a 20 20 20 20 65 72 |E_ICMP) |{. er|
|00002f50| 72 6f 72 28 22 57 61 72 | 6e 69 6e 67 3a 20 20 59 |ror("War|ning: Y|
|00002f60| 6f 75 20 61 72 65 20 6e | 6f 74 20 72 6f 6f 74 20 |ou are n|ot root |
|00002f70| 2d 2d 20 75 73 69 6e 67 | 20 54 43 50 20 70 69 6e |-- using| TCP pin|
|00002f80| 67 73 63 61 6e 20 72 61 | 74 68 65 72 20 74 68 61 |gscan ra|ther tha|
|00002f90| 6e 20 49 43 4d 50 22 29 | 3b 0a 20 20 20 20 6f 2e |n ICMP")|;. o.|
|00002fa0| 70 69 6e 67 74 79 70 65 | 20 3d 20 50 49 4e 47 54 |pingtype| = PINGT|
|00002fb0| 59 50 45 5f 54 43 50 3b | 0a 20 20 7d 0a 0a 20 20 |YPE_TCP;|. }.. |
|00002fc0| 69 66 20 28 6f 2e 66 69 | 6e 73 63 61 6e 20 7c 7c |if (o.fi|nscan |||
|00002fd0| 20 6f 2e 73 79 6e 73 63 | 61 6e 20 7c 7c 20 6f 2e | o.synsc|an || o.|
|00002fe0| 6d 61 69 6d 6f 6e 73 63 | 61 6e 20 7c 7c 20 6f 2e |maimonsc|an || o.|
|00002ff0| 6e 75 6c 6c 73 63 61 6e | 20 7c 7c 20 6f 2e 78 6d |nullscan| || o.xm|
|00003000| 61 73 73 63 61 6e 20 0a | 20 20 20 20 20 20 7c 7c |asscan .| |||
|00003010| 20 6f 2e 75 64 70 73 63 | 61 6e 20 29 20 7b 0a 20 | o.udpsc|an ) {. |
|00003020| 20 20 20 66 61 74 61 6c | 28 22 59 6f 75 20 72 65 | fatal|("You re|
|00003030| 71 75 65 73 74 65 64 20 | 61 20 73 63 61 6e 20 74 |quested |a scan t|
|00003040| 79 70 65 20 77 68 69 63 | 68 20 72 65 71 75 69 72 |ype whic|h requir|
|00003050| 65 73 20 72 30 30 74 20 | 70 72 69 76 69 6c 65 67 |es r00t |privileg|
|00003060| 65 73 2c 20 61 6e 64 20 | 79 6f 75 20 64 6f 20 6e |es, and |you do n|
|00003070| 6f 74 20 68 61 76 65 20 | 74 68 65 6d 2e 5c 6e 22 |ot have |them.\n"|
|00003080| 29 3b 0a 20 20 7d 0a 20 | 20 0a 20 20 69 66 20 28 |);. }. | . if (|
|00003090| 6f 2e 6e 75 6d 64 65 63 | 6f 79 73 20 3e 20 30 29 |o.numdec|oys > 0)|
|000030a0| 20 7b 0a 20 20 20 20 66 | 61 74 61 6c 28 22 53 6f | {. f|atal("So|
|000030b0| 72 72 79 2c 20 62 75 74 | 20 79 6f 75 27 76 65 20 |rry, but| you've |
|000030c0| 67 6f 74 20 74 6f 20 62 | 65 20 72 30 30 74 20 74 |got to b|e r00t t|
|000030d0| 6f 20 75 73 65 20 64 65 | 63 6f 79 73 2c 20 62 6f |o use de|coys, bo|
|000030e0| 79 21 22 29 3b 0a 20 20 | 7d 0a 20 20 0a 20 20 69 |y!");. |}. . i|
|000030f0| 66 20 28 6f 2e 66 72 61 | 67 73 63 61 6e 29 20 7b |f (o.fra|gscan) {|
|00003100| 0a 20 20 20 20 66 61 74 | 61 6c 28 22 53 6f 72 72 |. fat|al("Sorr|
|00003110| 79 2c 20 62 75 74 20 66 | 72 61 67 73 63 61 6e 20 |y, but f|ragscan |
|00003120| 72 65 71 75 69 72 65 73 | 20 72 30 30 74 20 70 72 |requires| r00t pr|
|00003130| 69 76 69 6c 65 67 65 73 | 5c 6e 22 29 3b 0a 20 20 |ivileges|\n");. |
|00003140| 7d 0a 0a 20 20 69 66 20 | 28 6f 2e 6f 73 73 63 61 |}.. if |(o.ossca|
|00003150| 6e 29 20 7b 0a 20 20 20 | 20 66 61 74 61 6c 28 22 |n) {. | fatal("|
|00003160| 54 43 50 2f 49 50 20 66 | 69 6e 67 65 72 70 72 69 |TCP/IP f|ingerpri|
|00003170| 6e 74 69 6e 67 20 28 66 | 6f 72 20 4f 53 20 73 63 |nting (f|or OS sc|
|00003180| 61 6e 29 20 72 65 71 75 | 69 72 65 73 20 72 6f 6f |an) requ|ires roo|
|00003190| 74 20 70 72 69 76 69 6c | 65 67 65 73 20 77 68 69 |t privil|eges whi|
|000031a0| 63 68 20 79 6f 75 20 64 | 6f 20 6e 6f 74 20 61 70 |ch you d|o not ap|
|000031b0| 70 65 61 72 20 74 6f 20 | 70 6f 73 73 65 73 73 2e |pear to |possess.|
|000031c0| 20 20 53 6f 72 72 79 2c | 20 64 75 64 65 2e 5c 6e | Sorry,| dude.\n|
|000031d0| 22 29 3b 0a 20 20 7d 0a | 7d 0a 0a 69 66 20 28 6f |");. }.|}..if (o|
|000031e0| 2e 62 6f 75 6e 63 65 73 | 63 61 6e 20 26 26 20 6f |.bounces|can && o|
|000031f0| 2e 70 69 6e 67 74 79 70 | 65 20 21 3d 20 50 49 4e |.pingtyp|e != PIN|
|00003200| 47 54 59 50 45 5f 4e 4f | 4e 45 29 20 0a 20 20 66 |GTYPE_NO|NE) . f|
|00003210| 70 72 69 6e 74 66 28 6f | 2e 6e 6d 61 70 5f 73 74 |printf(o|.nmap_st|
|00003220| 64 6f 75 74 2c 20 22 48 | 69 6e 74 3a 20 69 66 20 |dout, "H|int: if |
|00003230| 79 6f 75 72 20 62 6f 75 | 6e 63 65 20 73 63 61 6e |your bou|nce scan|
|00003240| 20 74 61 72 67 65 74 20 | 68 6f 73 74 73 20 61 72 | target |hosts ar|
|00003250| 65 6e 27 74 20 72 65 61 | 63 68 61 62 6c 65 20 66 |en't rea|chable f|
|00003260| 72 6f 6d 20 68 65 72 65 | 2c 20 72 65 6d 65 6d 62 |rom here|, rememb|
|00003270| 65 72 20 74 6f 20 75 73 | 65 20 2d 50 30 20 73 6f |er to us|e -P0 so|
|00003280| 20 77 65 20 64 6f 6e 27 | 74 20 74 72 79 20 61 6e | we don'|t try an|
|00003290| 64 20 70 69 6e 67 20 74 | 68 65 6d 20 70 72 69 6f |d ping t|hem prio|
|000032a0| 72 20 74 6f 20 74 68 65 | 20 73 63 61 6e 5c 6e 22 |r to the| scan\n"|
|000032b0| 29 3b 0a 0a 69 66 20 28 | 6f 2e 63 6f 6e 6e 65 63 |);..if (|o.connec|
|000032c0| 74 73 63 61 6e 20 2b 20 | 6f 2e 73 79 6e 73 63 61 |tscan + |o.synsca|
|000032d0| 6e 20 2b 20 6f 2e 66 69 | 6e 73 63 61 6e 20 2b 20 |n + o.fi|nscan + |
|000032e0| 6f 2e 6d 61 69 6d 6f 6e | 73 63 61 6e 20 2b 20 6f |o.maimon|scan + o|
|000032f0| 2e 78 6d 61 73 73 63 61 | 6e 20 2b 20 6f 2e 6e 75 |.xmassca|n + o.nu|
|00003300| 6c 6c 73 63 61 6e 20 3e | 20 31 29 20 7b 0a 20 20 |llscan >| 1) {. |
|00003310| 66 61 74 61 6c 28 22 59 | 6f 75 20 73 70 65 63 69 |fatal("Y|ou speci|
|00003320| 66 69 65 64 20 6d 6f 72 | 65 20 74 68 61 6e 20 6f |fied mor|e than o|
|00003330| 6e 65 20 74 79 70 65 20 | 6f 66 20 54 43 50 20 73 |ne type |of TCP s|
|00003340| 63 61 6e 2e 20 20 50 6c | 65 61 73 65 20 63 68 6f |can. Pl|ease cho|
|00003350| 6f 73 65 20 6f 6e 6c 79 | 20 6f 6e 65 20 6f 66 20 |ose only| one of |
|00003360| 2d 73 54 2c 20 2d 73 53 | 2c 20 2d 73 46 2c 20 2d |-sT, -sS|, -sF, -|
|00003370| 73 4d 2c 20 2d 73 58 2c | 20 61 6e 64 20 2d 73 4e |sM, -sX,| and -sN|
|00003380| 22 29 3b 0a 7d 0a 0a 69 | 66 20 28 6f 2e 6e 75 6d |");.}..i|f (o.num|
|00003390| 64 65 63 6f 79 73 20 3e | 20 30 20 26 26 20 28 6f |decoys >| 0 && (o|
|000033a0| 2e 62 6f 75 6e 63 65 73 | 63 61 6e 20 7c 7c 20 6f |.bounces|can || o|
|000033b0| 2e 63 6f 6e 6e 65 63 74 | 73 63 61 6e 29 29 20 7b |.connect|scan)) {|
|000033c0| 0a 20 20 66 61 74 61 6c | 28 22 44 65 63 6f 79 73 |. fatal|("Decoys|
|000033d0| 20 61 72 65 20 69 72 72 | 65 6c 65 76 61 6e 74 20 | are irr|elevant |
|000033e0| 74 6f 20 74 68 65 20 62 | 6f 75 6e 63 65 20 6f 72 |to the b|ounce or|
|000033f0| 20 63 6f 6e 6e 65 63 74 | 20 73 63 61 6e 73 22 29 | connect| scans")|
|00003400| 3b 0a 7d 0a 0a 69 66 20 | 28 6f 2e 66 72 61 67 73 |;.}..if |(o.frags|
|00003410| 63 61 6e 20 26 26 20 28 | 6f 2e 63 6f 6e 6e 65 63 |can && (|o.connec|
|00003420| 74 73 63 61 6e 20 7c 7c | 20 0a 09 09 20 20 20 28 |tscan ||| ... (|
|00003430| 6f 2e 75 64 70 73 63 61 | 6e 20 26 26 20 28 6f 2e |o.udpsca|n && (o.|
|00003440| 73 79 6e 73 63 61 6e 20 | 2b 20 6f 2e 66 69 6e 73 |synscan |+ o.fins|
|00003450| 63 61 6e 20 2b 20 6f 2e | 6d 61 69 6d 6f 6e 73 63 |can + o.|maimonsc|
|00003460| 61 6e 20 2b 20 0a 09 09 | 09 09 20 20 6f 2e 78 6d |an + ...|.. o.xm|
|00003470| 61 73 73 63 61 6e 20 2b | 20 6f 2e 6e 75 6c 6c 73 |asscan +| o.nulls|
|00003480| 63 61 6e 20 3d 3d 20 30 | 29 29 29 29 0a 20 20 66 |can == 0|)))). f|
|00003490| 61 74 61 6c 28 22 46 72 | 61 67 6d 65 6e 74 61 74 |atal("Fr|agmentat|
|000034a0| 69 6f 6e 20 73 63 61 6e | 20 63 61 6e 20 6f 6e 6c |ion scan| can onl|
|000034b0| 79 20 62 65 20 75 73 65 | 64 20 77 69 74 68 20 53 |y be use|d with S|
|000034c0| 59 4e 2c 20 46 49 4e 2c | 20 4d 61 69 6d 6f 6e 2c |YN, FIN,| Maimon,|
|000034d0| 20 58 4d 41 53 2c 20 6f | 72 20 4e 55 4c 4c 20 73 | XMAS, o|r NULL s|
|000034e0| 63 61 6e 20 74 79 70 65 | 73 22 29 3b 0a 20 0a 69 |can type|s");. .i|
|000034f0| 66 20 28 6f 2e 69 64 65 | 6e 74 73 63 61 6e 20 26 |f (o.ide|ntscan &|
|00003500| 26 20 21 6f 2e 63 6f 6e | 6e 65 63 74 73 63 61 6e |& !o.con|nectscan|
|00003510| 29 20 7b 0a 20 20 65 72 | 72 6f 72 28 22 49 64 65 |) {. er|ror("Ide|
|00003520| 6e 74 73 63 61 6e 20 6f | 6e 6c 79 20 77 6f 72 6b |ntscan o|nly work|
|00003530| 73 20 77 69 74 68 20 63 | 6f 6e 6e 65 63 74 20 73 |s with c|onnect s|
|00003540| 63 61 6e 20 28 2d 73 54 | 29 20 2e 2e 2e 20 69 67 |can (-sT|) ... ig|
|00003550| 6e 6f 72 69 6e 67 20 6f | 70 74 69 6f 6e 22 29 3b |noring o|ption");|
|00003560| 0a 7d 0a 0a 69 66 20 28 | 6f 2e 6f 73 73 63 61 6e |.}..if (|o.osscan|
|00003570| 20 26 26 20 6f 2e 62 6f | 75 6e 63 65 73 63 61 6e | && o.bo|uncescan|
|00003580| 29 0a 20 20 65 72 72 6f | 72 28 22 43 6f 6d 62 69 |). erro|r("Combi|
|00003590| 6e 69 6e 67 20 62 6f 75 | 6e 63 65 20 73 63 61 6e |ning bou|nce scan|
|000035a0| 20 77 69 74 68 20 4f 53 | 20 73 63 61 6e 20 73 65 | with OS| scan se|
|000035b0| 65 6d 73 20 73 69 6c 6c | 79 2c 20 62 75 74 20 49 |ems sill|y, but I|
|000035c0| 20 77 69 6c 6c 20 6c 65 | 74 20 79 6f 75 20 64 6f | will le|t you do|
|000035d0| 20 77 68 61 74 65 76 65 | 72 20 79 6f 75 20 77 61 | whateve|r you wa|
|000035e0| 6e 74 21 22 29 3b 0a 0a | 23 69 66 20 21 64 65 66 |nt!");..|#if !def|
|000035f0| 69 6e 65 64 28 4c 49 4e | 55 58 29 20 26 26 20 21 |ined(LIN|UX) && !|
|00003600| 64 65 66 69 6e 65 64 28 | 4f 50 45 4e 42 53 44 29 |defined(|OPENBSD)|
|00003610| 20 26 26 20 21 64 65 66 | 69 6e 65 64 28 46 52 45 | && !def|ined(FRE|
|00003620| 45 42 53 44 29 20 26 26 | 20 21 64 65 66 69 6e 65 |EBSD) &&| !define|
|00003630| 64 28 4e 45 54 42 53 44 | 29 0a 20 69 66 20 28 6f |d(NETBSD|). if (o|
|00003640| 2e 66 72 61 67 73 63 61 | 6e 29 20 7b 0a 20 20 20 |.fragsca|n) {. |
|00003650| 66 70 72 69 6e 74 66 28 | 73 74 64 65 72 72 2c 20 |fprintf(|stderr, |
|00003660| 22 57 61 72 6e 69 6e 67 | 3a 20 50 61 63 6b 65 74 |"Warning|: Packet|
|00003670| 20 66 72 61 67 6d 65 6e | 74 61 74 69 6f 6e 20 73 | fragmen|tation s|
|00003680| 65 6c 65 63 74 65 64 20 | 6f 6e 20 61 20 68 6f 73 |elected |on a hos|
|00003690| 74 20 6f 74 68 65 72 20 | 74 68 61 6e 20 4c 69 6e |t other |than Lin|
|000036a0| 75 78 2c 20 4f 70 65 6e | 42 53 44 2c 20 46 72 65 |ux, Open|BSD, Fre|
|000036b0| 65 42 53 44 2c 20 6f 72 | 20 4e 65 74 42 53 44 2e |eBSD, or| NetBSD.|
|000036c0| 20 20 54 68 69 73 20 6d | 61 79 20 6f 72 20 6d 61 | This m|ay or ma|
|000036d0| 79 20 6e 6f 74 20 77 6f | 72 6b 2e 5c 6e 22 29 3b |y not wo|rk.\n");|
|000036e0| 0a 20 7d 0a 23 65 6e 64 | 69 66 0a 0a 69 66 20 28 |. }.#end|if..if (|
|000036f0| 6f 2e 6d 61 78 5f 73 6f | 63 6b 65 74 73 20 3e 20 |o.max_so|ckets > |
|00003700| 4d 41 58 5f 53 4f 43 4b | 45 54 53 5f 41 4c 4c 4f |MAX_SOCK|ETS_ALLO|
|00003710| 57 45 44 29 20 7b 0a 20 | 20 20 65 72 72 6f 72 28 |WED) {. | error(|
|00003720| 22 57 61 72 6e 69 6e 67 | 3a 20 59 6f 75 20 61 72 |"Warning|: You ar|
|00003730| 65 20 6c 69 6d 69 74 65 | 64 20 74 6f 20 4d 41 58 |e limite|d to MAX|
|00003740| 5f 53 4f 43 4b 45 54 53 | 5f 41 4c 4c 4f 57 45 44 |_SOCKETS|_ALLOWED|
|00003750| 20 28 25 64 29 20 70 61 | 72 61 6c 6c 65 6c 20 73 | (%d) pa|rallel s|
|00003760| 6f 63 6b 65 74 73 2e 20 | 20 49 66 20 79 6f 75 20 |ockets. | If you |
|00003770| 72 65 61 6c 6c 79 20 6e | 65 65 64 20 6d 6f 72 65 |really n|eed more|
|00003780| 2c 20 63 68 61 6e 67 65 | 20 74 68 65 20 23 64 65 |, change| the #de|
|00003790| 66 69 6e 65 20 61 6e 64 | 20 72 65 63 6f 6d 70 69 |fine and| recompi|
|000037a0| 6c 65 2e 5c 6e 22 2c 20 | 4d 41 58 5f 53 4f 43 4b |le.\n", |MAX_SOCK|
|000037b0| 45 54 53 5f 41 4c 4c 4f | 57 45 44 29 3b 0a 20 20 |ETS_ALLO|WED);. |
|000037c0| 20 6f 2e 6d 61 78 5f 73 | 6f 63 6b 65 74 73 20 3d | o.max_s|ockets =|
|000037d0| 20 4d 41 58 5f 53 4f 43 | 4b 45 54 53 5f 41 4c 4c | MAX_SOC|KETS_ALL|
|000037e0| 4f 57 45 44 3b 0a 7d 0a | 0a 69 66 20 28 6f 2e 6f |OWED;.}.|.if (o.o|
|000037f0| 73 73 63 61 6e 20 26 26 | 20 6f 2e 70 69 6e 67 73 |sscan &&| o.pings|
|00003800| 63 61 6e 29 20 7b 0a 20 | 20 66 61 74 61 6c 28 22 |can) {. | fatal("|
|00003810| 57 41 52 4e 49 4e 47 3a | 20 20 4f 53 20 53 63 61 |WARNING:| OS Sca|
|00003820| 6e 20 69 73 20 75 6e 72 | 65 6c 69 61 62 6c 65 20 |n is unr|eliable |
|00003830| 77 69 74 68 20 61 20 70 | 69 6e 67 20 73 63 61 6e |with a p|ing scan|
|00003840| 2e 20 20 59 6f 75 20 6e | 65 65 64 20 74 6f 20 75 |. You n|eed to u|
|00003850| 73 65 20 61 20 73 63 61 | 6e 20 74 79 70 65 20 61 |se a sca|n type a|
|00003860| 6c 6f 6e 67 20 77 69 74 | 68 20 69 74 2c 20 73 75 |long wit|h it, su|
|00003870| 63 68 20 61 73 20 2d 73 | 53 2c 20 2d 73 54 2c 20 |ch as -s|S, -sT, |
|00003880| 2d 73 46 2c 20 65 74 63 | 20 69 6e 73 74 65 61 64 |-sF, etc| instead|
|00003890| 20 6f 66 20 2d 73 50 22 | 29 3b 0a 7d 0a 0a 69 66 | of -sP"|);.}..if|
|000038a0| 20 28 6f 2e 6d 61 67 69 | 63 5f 70 6f 72 74 5f 73 | (o.magi|c_port_s|
|000038b0| 65 74 20 26 26 20 6f 2e | 63 6f 6e 6e 65 63 74 73 |et && o.|connects|
|000038c0| 63 61 6e 29 20 7b 0a 20 | 20 65 72 72 6f 72 28 22 |can) {. | error("|
|000038d0| 57 41 52 4e 49 4e 47 3a | 20 20 2d 67 20 69 73 20 |WARNING:| -g is |
|000038e0| 69 6e 63 6f 6d 70 61 74 | 69 62 6c 65 20 77 69 74 |incompat|ible wit|
|000038f0| 68 20 74 68 65 20 64 65 | 66 61 75 6c 74 20 63 6f |h the de|fault co|
|00003900| 6e 6e 65 63 74 28 29 20 | 73 63 61 6e 20 28 2d 73 |nnect() |scan (-s|
|00003910| 54 29 2e 20 20 55 73 65 | 20 61 20 72 61 77 20 73 |T). Use| a raw s|
|00003920| 63 61 6e 20 73 75 63 68 | 20 61 73 20 2d 73 53 20 |can such| as -sS |
|00003930| 69 66 20 79 6f 75 20 77 | 61 6e 74 20 74 6f 20 73 |if you w|ant to s|
|00003940| 65 74 20 74 68 65 20 73 | 6f 75 72 63 65 20 70 6f |et the s|ource po|
|00003950| 72 74 2e 22 29 3b 0a 7d | 0a 0a 2f 2a 20 53 65 74 |rt.");.}|../* Set|
|00003960| 20 75 70 20 6f 75 72 20 | 61 72 72 61 79 20 6f 66 | up our |array of|
|00003970| 20 64 65 63 6f 79 73 21 | 20 2a 2f 0a 69 66 20 28 | decoys!| */.if (|
|00003980| 6f 2e 64 65 63 6f 79 74 | 75 72 6e 20 3d 3d 20 2d |o.decoyt|urn == -|
|00003990| 31 29 20 7b 0a 20 20 6f | 2e 64 65 63 6f 79 74 75 |1) {. o|.decoytu|
|000039a0| 72 6e 20 3d 20 28 6f 2e | 6e 75 6d 64 65 63 6f 79 |rn = (o.|numdecoy|
|000039b0| 73 20 3d 3d 20 30 29 3f | 20 20 30 20 3a 20 67 65 |s == 0)?| 0 : ge|
|000039c0| 74 5f 72 61 6e 64 6f 6d | 5f 75 69 6e 74 28 29 20 |t_random|_uint() |
|000039d0| 25 20 6f 2e 6e 75 6d 64 | 65 63 6f 79 73 3b 20 0a |% o.numd|ecoys; .|
|000039e0| 20 20 6f 2e 6e 75 6d 64 | 65 63 6f 79 73 2b 2b 3b | o.numd|ecoys++;|
|000039f0| 0a 20 20 66 6f 72 28 69 | 3d 6f 2e 6e 75 6d 64 65 |. for(i|=o.numde|
|00003a00| 63 6f 79 73 2d 31 3b 20 | 69 20 3e 20 6f 2e 64 65 |coys-1; |i > o.de|
|00003a10| 63 6f 79 74 75 72 6e 3b | 20 69 2d 2d 29 0a 20 20 |coyturn;| i--). |
|00003a20| 20 20 6f 2e 64 65 63 6f | 79 73 5b 69 5d 20 3d 20 | o.deco|ys[i] = |
|00003a30| 6f 2e 64 65 63 6f 79 73 | 5b 69 2d 31 5d 3b 0a 7d |o.decoys|[i-1];.}|
|00003a40| 0a 0a 2f 2a 20 57 65 20 | 6e 65 65 64 20 74 6f 20 |../* We |need to |
|00003a50| 66 69 6e 64 20 77 68 61 | 74 20 69 6e 74 65 72 66 |find wha|t interf|
|00003a60| 61 63 65 20 74 6f 20 72 | 6f 75 74 65 20 74 68 72 |ace to r|oute thr|
|00003a70| 6f 75 67 68 20 69 66 3a | 0a 20 2a 20 2d 2d 4e 6f |ough if:|. * --No|
|00003a80| 6e 65 20 68 61 76 65 20 | 62 65 65 6e 20 73 70 65 |ne have |been spe|
|00003a90| 63 69 66 69 65 64 20 41 | 4e 44 0a 20 2a 20 2d 2d |cified A|ND. * --|
|00003aa0| 57 65 20 61 72 65 20 72 | 6f 6f 74 20 61 6e 64 20 |We are r|oot and |
|00003ab0| 64 6f 69 6e 67 20 74 63 | 70 20 70 69 6e 67 20 4f |doing tc|p ping O|
|00003ac0| 52 0a 20 2a 20 2d 2d 57 | 65 20 61 72 65 20 64 6f |R. * --W|e are do|
|00003ad0| 69 6e 67 20 61 20 72 61 | 77 20 73 6f 63 6b 20 73 |ing a ra|w sock s|
|00003ae0| 63 61 6e 20 61 6e 64 20 | 4e 4f 54 20 70 69 6e 67 |can and |NOT ping|
|00003af0| 69 6e 67 20 61 6e 79 6f | 6e 65 20 2a 2f 0a 69 66 |ing anyo|ne */.if|
|00003b00| 20 28 6f 2e 73 6f 75 72 | 63 65 20 26 26 20 21 2a | (o.sour|ce && !*|
|00003b10| 6f 2e 64 65 76 69 63 65 | 29 20 7b 0a 20 20 69 66 |o.device|) {. if|
|00003b20| 20 28 69 70 61 64 64 72 | 32 64 65 76 6e 61 6d 65 | (ipaddr|2devname|
|00003b30| 28 6f 2e 64 65 76 69 63 | 65 2c 20 6f 2e 73 6f 75 |(o.devic|e, o.sou|
|00003b40| 72 63 65 29 20 21 3d 20 | 30 29 20 7b 0a 20 20 20 |rce) != |0) {. |
|00003b50| 20 66 61 74 61 6c 28 22 | 43 6f 75 6c 64 20 6e 6f | fatal("|Could no|
|00003b60| 74 20 66 69 67 75 72 65 | 20 6f 75 74 20 77 68 61 |t figure| out wha|
|00003b70| 74 20 64 65 76 69 63 65 | 20 74 6f 20 73 65 6e 64 |t device| to send|
|00003b80| 20 74 68 65 20 70 61 63 | 6b 65 74 20 6f 75 74 20 | the pac|ket out |
|00003b90| 6f 6e 20 77 69 74 68 20 | 74 68 65 20 73 6f 75 72 |on with |the sour|
|00003ba0| 63 65 20 61 64 64 72 65 | 73 73 20 79 6f 75 20 67 |ce addre|ss you g|
|00003bb0| 61 76 65 20 6d 65 21 20 | 20 49 66 20 79 6f 75 20 |ave me! | If you |
|00003bc0| 61 72 65 20 74 72 79 69 | 6e 67 20 74 6f 20 73 70 |are tryi|ng to sp|
|00003bd0| 30 30 66 20 79 6f 75 72 | 20 73 63 61 6e 2c 20 74 |00f your| scan, t|
|00003be0| 68 69 73 20 69 73 20 6e | 6f 72 6d 61 6c 2c 20 6a |his is n|ormal, j|
|00003bf0| 75 73 74 20 67 69 76 65 | 20 74 68 65 20 2d 65 20 |ust give| the -e |
|00003c00| 65 74 68 30 20 6f 72 20 | 2d 65 20 70 70 70 30 20 |eth0 or |-e ppp0 |
|00003c10| 6f 72 20 77 68 61 74 65 | 76 65 72 2e 20 20 4f 74 |or whate|ver. Ot|
|00003c20| 68 65 72 77 69 73 65 20 | 79 6f 75 20 63 61 6e 20 |herwise |you can |
|00003c30| 73 74 69 6c 6c 20 75 73 | 65 20 2d 65 2c 20 62 75 |still us|e -e, bu|
|00003c40| 74 20 49 20 66 69 6e 64 | 20 69 74 20 6b 69 6e 64 |t I find| it kind|
|00003c50| 6f 66 20 66 69 73 68 79 | 2e 22 29 3b 0a 20 20 7d |of fishy|.");. }|
|00003c60| 0a 7d 0a 0a 69 66 20 28 | 2a 6f 2e 64 65 76 69 63 |.}..if (|*o.devic|
|00003c70| 65 20 26 26 20 21 6f 2e | 73 6f 75 72 63 65 29 20 |e && !o.|source) |
|00003c80| 7b 0a 20 20 6f 2e 73 6f | 75 72 63 65 20 3d 20 73 |{. o.so|urce = s|
|00003c90| 61 66 65 5f 6d 61 6c 6c | 6f 63 28 73 69 7a 65 6f |afe_mall|oc(sizeo|
|00003ca0| 66 28 73 74 72 75 63 74 | 20 69 6e 5f 61 64 64 72 |f(struct| in_addr|
|00003cb0| 29 29 3b 20 0a 20 20 69 | 66 20 28 64 65 76 6e 61 |)); . i|f (devna|
|00003cc0| 6d 65 32 69 70 61 64 64 | 72 28 6f 2e 64 65 76 69 |me2ipadd|r(o.devi|
|00003cd0| 63 65 2c 20 6f 2e 73 6f | 75 72 63 65 29 20 3d 3d |ce, o.so|urce) ==|
|00003ce0| 20 2d 31 29 20 7b 0a 20 | 20 20 20 66 61 74 61 6c | -1) {. | fatal|
|00003cf0| 28 22 49 20 63 61 6e 6e | 6f 74 20 66 69 67 75 72 |("I cann|ot figur|
|00003d00| 65 20 6f 75 74 20 77 68 | 61 74 20 73 6f 75 72 63 |e out wh|at sourc|
|00003d10| 65 20 61 64 64 72 65 73 | 73 20 74 6f 20 75 73 65 |e addres|s to use|
|00003d20| 20 66 6f 72 20 64 65 76 | 69 63 65 20 25 73 2c 20 | for dev|ice %s, |
|00003d30| 64 6f 65 73 20 69 74 20 | 65 76 65 6e 20 65 78 69 |does it |even exi|
|00003d40| 73 74 3f 22 2c 20 6f 2e | 64 65 76 69 63 65 29 3b |st?", o.|device);|
|00003d50| 0a 20 20 7d 0a 7d 0a 0a | 0a 2f 2a 20 49 66 20 68 |. }.}..|./* If h|
|00003d60| 65 20 77 61 6e 74 73 20 | 74 6f 20 62 6f 75 6e 63 |e wants |to bounc|
|00003d70| 65 20 6f 66 66 20 6f 66 | 20 61 6e 20 66 74 70 20 |e off of| an ftp |
|00003d80| 73 69 74 65 2c 20 74 68 | 61 74 20 73 69 74 65 20 |site, th|at site |
|00003d90| 62 65 74 74 65 72 20 64 | 61 6d 6e 20 77 65 6c 6c |better d|amn well|
|00003da0| 20 62 65 20 72 65 61 63 | 68 61 62 6c 65 21 20 2a | be reac|hable! *|
|00003db0| 2f 0a 69 66 20 28 6f 2e | 62 6f 75 6e 63 65 73 63 |/.if (o.|bouncesc|
|00003dc0| 61 6e 29 20 7b 0a 20 20 | 69 66 20 28 21 69 6e 65 |an) {. |if (!ine|
|00003dd0| 74 5f 61 74 6f 6e 28 66 | 74 70 2e 73 65 72 76 65 |t_aton(f|tp.serve|
|00003de0| 72 5f 6e 61 6d 65 2c 20 | 26 66 74 70 2e 73 65 72 |r_name, |&ftp.ser|
|00003df0| 76 65 72 29 29 20 7b 0a | 20 20 20 20 69 66 20 28 |ver)) {.| if (|
|00003e00| 28 74 61 72 67 65 74 20 | 3d 20 67 65 74 68 6f 73 |(target |= gethos|
|00003e10| 74 62 79 6e 61 6d 65 28 | 66 74 70 2e 73 65 72 76 |tbyname(|ftp.serv|
|00003e20| 65 72 5f 6e 61 6d 65 29 | 29 29 0a 20 20 20 20 20 |er_name)|)). |
|00003e30| 20 6d 65 6d 63 70 79 28 | 26 66 74 70 2e 73 65 72 | memcpy(|&ftp.ser|
|00003e40| 76 65 72 2c 20 74 61 72 | 67 65 74 2d 3e 68 5f 61 |ver, tar|get->h_a|
|00003e50| 64 64 72 5f 6c 69 73 74 | 5b 30 5d 2c 20 34 29 3b |ddr_list|[0], 4);|
|00003e60| 0a 20 20 20 20 65 6c 73 | 65 20 7b 0a 20 20 20 20 |. els|e {. |
|00003e70| 20 20 66 70 72 69 6e 74 | 66 28 73 74 64 65 72 72 | fprint|f(stderr|
|00003e80| 2c 20 22 46 61 69 6c 65 | 64 20 74 6f 20 72 65 73 |, "Faile|d to res|
|00003e90| 6f 6c 76 65 20 66 74 70 | 20 62 6f 75 6e 63 65 20 |olve ftp| bounce |
|00003ea0| 70 72 6f 78 79 20 68 6f | 73 74 6e 61 6d 65 2f 49 |proxy ho|stname/I|
|00003eb0| 50 3a 20 25 73 5c 6e 22 | 2c 0a 09 20 20 20 20 20 |P: %s\n"|,.. |
|00003ec0| 20 66 74 70 2e 73 65 72 | 76 65 72 5f 6e 61 6d 65 | ftp.ser|ver_name|
|00003ed0| 29 3b 0a 20 20 20 20 20 | 20 65 78 69 74 28 31 29 |);. | exit(1)|
|00003ee0| 3b 0a 20 20 20 20 7d 20 | 0a 20 20 7d 20 20 65 6c |;. } |. } el|
|00003ef0| 73 65 20 69 66 20 28 6f | 2e 76 65 72 62 6f 73 65 |se if (o|.verbose|
|00003f00| 29 0a 20 20 20 20 66 70 | 72 69 6e 74 66 28 6f 2e |). fp|rintf(o.|
|00003f10| 6e 6d 61 70 5f 73 74 64 | 6f 75 74 2c 20 22 52 65 |nmap_std|out, "Re|
|00003f20| 73 6f 6c 76 65 64 20 66 | 74 70 20 62 6f 75 6e 63 |solved f|tp bounc|
|00003f30| 65 20 61 74 74 61 63 6b | 20 70 72 6f 78 79 20 74 |e attack| proxy t|
|00003f40| 6f 20 25 73 20 28 25 73 | 29 2e 5c 6e 22 2c 20 0a |o %s (%s|).\n", .|
|00003f50| 09 20 20 20 66 74 70 2e | 73 65 72 76 65 72 5f 6e |. ftp.|server_n|
|00003f60| 61 6d 65 2c 20 69 6e 65 | 74 5f 6e 74 6f 61 28 66 |ame, ine|t_ntoa(f|
|00003f70| 74 70 2e 73 65 72 76 65 | 72 29 29 3b 20 0a 7d 0a |tp.serve|r)); .}.|
|00003f80| 66 66 6c 75 73 68 28 73 | 74 64 6f 75 74 29 3b 0a |fflush(s|tdout);.|
|00003f90| 0a 69 66 20 28 6f 2e 6c | 6f 67 66 64 29 20 7b 0a |.if (o.l|ogfd) {.|
|00003fa0| 20 20 2f 2a 20 42 72 69 | 65 66 20 69 6e 66 6f 20 | /* Bri|ef info |
|00003fb0| 69 6e 63 61 73 65 20 74 | 68 65 79 20 66 6f 72 67 |incase t|hey forg|
|00003fc0| 65 74 20 77 68 61 74 20 | 77 61 73 20 73 63 61 6e |et what |was scan|
|00003fd0| 6e 65 64 20 2a 2f 0a 20 | 20 66 70 72 69 6e 74 66 |ned */. | fprintf|
|00003fe0| 28 6f 2e 6c 6f 67 66 64 | 2c 20 22 23 20 4c 6f 67 |(o.logfd|, "# Log|
|00003ff0| 20 6f 66 3a 20 22 29 3b | 0a 20 20 66 6f 72 28 69 | of: ");|. for(i|
|00004000| 3d 30 3b 20 69 20 3c 20 | 61 72 67 63 3b 20 69 2b |=0; i < |argc; i+|
|00004010| 2b 29 0a 20 20 20 20 66 | 70 72 69 6e 74 66 28 6f |+). f|printf(o|
|00004020| 2e 6c 6f 67 66 64 2c 20 | 22 25 73 20 22 2c 20 66 |.logfd, |"%s ", f|
|00004030| 61 6b 65 61 72 67 76 5b | 69 5d 29 3b 0a 20 20 66 |akeargv[|i]);. f|
|00004040| 70 72 69 6e 74 66 28 6f | 2e 6c 6f 67 66 64 2c 20 |printf(o|.logfd, |
|00004050| 22 5c 6e 22 29 3b 0a 7d | 0a 0a 0a 0a 2f 2a 20 6d |"\n");.}|..../* m|
|00004060| 6f 72 65 20 66 61 6b 65 | 61 72 67 76 20 6a 75 6e |ore fake|argv jun|
|00004070| 6b 2c 20 42 54 57 20 6d | 61 6c 6c 6f 63 27 69 6e |k, BTW m|alloc'in|
|00004080| 67 20 65 78 74 72 61 20 | 73 70 61 63 65 20 69 6e |g extra |space in|
|00004090| 20 61 72 67 76 5b 30 5d | 20 64 6f 65 73 6e 27 74 | argv[0]| doesn't|
|000040a0| 20 77 6f 72 6b 20 2a 2f | 0a 69 66 20 28 71 75 61 | work */|.if (qua|
|000040b0| 73 68 61 72 67 76 29 20 | 7b 0a 20 20 61 72 67 76 |shargv) |{. argv|
|000040c0| 6c 65 6e 20 3d 20 73 74 | 72 6c 65 6e 28 61 72 67 |len = st|rlen(arg|
|000040d0| 76 5b 30 5d 29 3b 0a 20 | 20 69 66 20 28 61 72 67 |v[0]);. | if (arg|
|000040e0| 76 6c 65 6e 20 3c 20 73 | 74 72 6c 65 6e 28 46 41 |vlen < s|trlen(FA|
|000040f0| 4b 45 5f 41 52 47 56 29 | 29 0a 20 20 20 20 66 61 |KE_ARGV)|). fa|
|00004100| 74 61 6c 28 22 49 66 20 | 79 6f 75 20 77 61 6e 74 |tal("If |you want|
|00004110| 20 6d 65 20 74 6f 20 66 | 61 6b 65 20 79 6f 75 72 | me to f|ake your|
|00004120| 20 61 72 67 76 2c 20 79 | 6f 75 20 6e 65 65 64 20 | argv, y|ou need |
|00004130| 74 6f 20 63 61 6c 6c 20 | 74 68 65 20 70 72 6f 67 |to call |the prog|
|00004140| 72 61 6d 20 77 69 74 68 | 20 61 20 6c 6f 6e 67 65 |ram with| a longe|
|00004150| 72 20 6e 61 6d 65 2e 20 | 20 54 72 79 20 74 68 65 |r name. | Try the|
|00004160| 20 66 75 6c 6c 20 70 61 | 74 68 6e 61 6d 65 2c 20 | full pa|thname, |
|00004170| 6f 72 20 72 65 6e 61 6d | 65 20 69 74 20 66 79 6f |or renam|e it fyo|
|00004180| 64 6f 72 73 73 75 70 65 | 72 64 65 64 6f 75 70 65 |dorssupe|rdedoupe|
|00004190| 72 70 6f 72 74 73 63 61 | 6e 6e 65 72 22 29 3b 0a |rportsca|nner");.|
|000041a0| 20 20 73 74 72 6e 63 70 | 79 28 61 72 67 76 5b 30 | strncp|y(argv[0|
|000041b0| 5d 2c 20 46 41 4b 45 5f | 41 52 47 56 2c 20 73 74 |], FAKE_|ARGV, st|
|000041c0| 72 6c 65 6e 28 46 41 4b | 45 5f 41 52 47 56 29 29 |rlen(FAK|E_ARGV))|
|000041d0| 3b 0a 20 20 66 6f 72 28 | 69 20 3d 20 73 74 72 6c |;. for(|i = strl|
|000041e0| 65 6e 28 46 41 4b 45 5f | 41 52 47 56 29 3b 20 69 |en(FAKE_|ARGV); i|
|000041f0| 20 3c 20 61 72 67 76 6c | 65 6e 3b 20 69 2b 2b 29 | < argvl|en; i++)|
|00004200| 20 61 72 67 76 5b 30 5d | 5b 69 5d 20 3d 20 27 5c | argv[0]|[i] = '\|
|00004210| 30 27 3b 0a 20 20 66 6f | 72 28 69 3d 31 3b 20 69 |0';. fo|r(i=1; i|
|00004220| 20 3c 20 61 72 67 63 3b | 20 69 2b 2b 29 20 7b 0a | < argc;| i++) {.|
|00004230| 20 20 20 20 61 72 67 76 | 6c 65 6e 20 3d 20 73 74 | argv|len = st|
|00004240| 72 6c 65 6e 28 61 72 67 | 76 5b 69 5d 29 3b 0a 20 |rlen(arg|v[i]);. |
|00004250| 20 20 20 66 6f 72 28 6a | 3d 30 3b 20 6a 20 3c 3d | for(j|=0; j <=|
|00004260| 20 61 72 67 76 6c 65 6e | 3b 20 6a 2b 2b 29 0a 20 | argvlen|; j++). |
|00004270| 20 20 20 20 20 61 72 67 | 76 5b 69 5d 5b 6a 5d 20 | arg|v[i][j] |
|00004280| 3d 20 27 5c 30 27 3b 0a | 20 20 7d 0a 7d 0a 0a 73 |= '\0';.| }.}..s|
|00004290| 69 67 6e 61 6c 28 53 49 | 47 50 49 50 45 2c 20 53 |ignal(SI|GPIPE, S|
|000042a0| 49 47 5f 49 47 4e 29 3b | 20 2f 2a 20 69 67 6e 6f |IG_IGN);| /* igno|
|000042b0| 72 65 20 53 49 47 50 49 | 50 45 20 73 6f 20 6f 75 |re SIGPI|PE so ou|
|000042c0| 72 20 70 72 6f 67 72 61 | 6d 20 64 6f 65 73 6e 27 |r progra|m doesn'|
|000042d0| 74 20 63 72 61 73 68 20 | 62 65 63 61 75 73 65 0a |t crash |because.|
|000042e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000042f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 6f 66 20 | | of |
|00004300| 69 74 2c 20 62 75 74 20 | 77 65 20 72 65 61 6c 6c |it, but |we reall|
|00004310| 79 20 73 68 6f 75 6c 64 | 6e 27 74 20 67 65 74 20 |y should|n't get |
|00004320| 61 6e 20 75 6e 73 75 73 | 70 65 63 74 65 64 0a 20 |an unsus|pected. |
|00004330| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00004340| 20 20 20 20 20 20 20 20 | 20 20 20 20 53 49 47 50 | | SIGP|
|00004350| 49 50 45 20 2a 2f 0a 69 | 66 20 28 6f 2e 6d 61 78 |IPE */.i|f (o.max|
|00004360| 5f 73 6f 63 6b 65 74 73 | 20 26 26 20 28 69 20 3d |_sockets| && (i =|
|00004370| 20 6d 61 78 5f 73 64 28 | 29 29 20 26 26 20 69 20 | max_sd(|)) && i |
|00004380| 3c 20 6f 2e 6d 61 78 5f | 73 6f 63 6b 65 74 73 29 |< o.max_|sockets)|
|00004390| 20 7b 0a 20 20 66 70 72 | 69 6e 74 66 28 73 74 64 | {. fpr|intf(std|
|000043a0| 65 72 72 2c 20 22 57 41 | 52 4e 49 4e 47 3a 20 20 |err, "WA|RNING: |
|000043b0| 59 6f 75 72 20 73 70 65 | 63 69 66 69 65 64 20 6d |Your spe|cified m|
|000043c0| 61 78 5f 70 61 72 61 6c | 6c 65 6c 5f 73 6f 63 6b |ax_paral|lel_sock|
|000043d0| 65 74 73 20 6f 66 20 25 | 64 2c 20 62 75 74 20 79 |ets of %|d, but y|
|000043e0| 6f 75 72 20 73 79 73 74 | 65 6d 20 73 61 79 73 20 |our syst|em says |
|000043f0| 69 74 20 6d 69 67 68 74 | 20 6f 6e 6c 79 20 67 69 |it might| only gi|
|00004400| 76 65 20 75 73 20 25 64 | 2e 20 20 54 72 79 69 6e |ve us %d|. Tryin|
|00004410| 67 20 61 6e 79 77 61 79 | 5c 6e 22 2c 20 6f 2e 6d |g anyway|\n", o.m|
|00004420| 61 78 5f 73 6f 63 6b 65 | 74 73 2c 20 69 29 3b 0a |ax_socke|ts, i);.|
|00004430| 7d 0a 0a 69 66 20 28 21 | 6f 2e 6d 61 78 5f 73 6f |}..if (!|o.max_so|
|00004440| 63 6b 65 74 73 29 20 7b | 0a 20 20 6f 2e 6d 61 78 |ckets) {|. o.max|
|00004450| 5f 73 6f 63 6b 65 74 73 | 20 3d 20 6d 61 78 5f 73 |_sockets| = max_s|
|00004460| 64 28 29 3b 0a 20 20 69 | 66 20 28 21 6f 2e 6d 61 |d();. i|f (!o.ma|
|00004470| 78 5f 73 6f 63 6b 65 74 | 73 29 0a 20 20 20 20 6f |x_socket|s). o|
|00004480| 2e 6d 61 78 5f 73 6f 63 | 6b 65 74 73 20 3d 20 36 |.max_soc|kets = 6|
|00004490| 30 3b 0a 20 20 65 6c 73 | 65 20 69 66 20 28 6f 2e |0;. els|e if (o.|
|000044a0| 6d 61 78 5f 73 6f 63 6b | 65 74 73 20 3e 20 35 29 |max_sock|ets > 5)|
|000044b0| 0a 20 20 20 20 6f 2e 6d | 61 78 5f 73 6f 63 6b 65 |. o.m|ax_socke|
|000044c0| 74 73 20 2d 3d 20 34 3b | 20 2f 2a 20 54 6f 20 6d |ts -= 4;| /* To m|
|000044d0| 61 6b 65 20 75 70 20 66 | 6f 72 20 6d 69 73 63 2e |ake up f|or misc.|
|000044e0| 20 75 6e 63 6f 75 6e 74 | 65 64 20 73 6f 63 6b 65 | uncount|ed socke|
|000044f0| 74 73 20 2a 2f 0a 20 20 | 6f 2e 6d 61 78 5f 73 6f |ts */. |o.max_so|
|00004500| 63 6b 65 74 73 20 3d 20 | 4d 49 4e 28 6f 2e 6d 61 |ckets = |MIN(o.ma|
|00004510| 78 5f 73 6f 63 6b 65 74 | 73 2c 20 31 32 35 29 3b |x_socket|s, 125);|
|00004520| 0a 7d 0a 0a 69 66 20 28 | 6f 2e 64 65 62 75 67 67 |.}..if (|o.debugg|
|00004530| 69 6e 67 20 3e 20 31 29 | 20 66 70 72 69 6e 74 66 |ing > 1)| fprintf|
|00004540| 28 6f 2e 6e 6d 61 70 5f | 73 74 64 6f 75 74 2c 20 |(o.nmap_|stdout, |
|00004550| 22 54 68 65 20 6d 61 78 | 20 23 20 6f 66 20 73 6f |"The max| # of so|
|00004560| 63 6b 65 74 73 20 77 65 | 20 61 72 65 20 75 73 69 |ckets we| are usi|
|00004570| 6e 67 20 69 73 3a 20 25 | 64 5c 6e 22 2c 20 6f 2e |ng is: %|d\n", o.|
|00004580| 6d 61 78 5f 73 6f 63 6b | 65 74 73 29 3b 0a 0a 69 |max_sock|ets);..i|
|00004590| 66 20 28 72 61 6e 64 6f | 6d 69 7a 65 29 0a 20 20 |f (rando|mize). |
|000045a0| 73 68 6f 72 74 66 72 79 | 28 70 6f 72 74 73 29 3b |shortfry|(ports);|
|000045b0| 20 0a 0a 73 74 61 72 74 | 74 69 6d 65 20 3d 20 74 | ..start|time = t|
|000045c0| 69 6d 65 28 4e 55 4c 4c | 29 3b 0a 0a 77 68 69 6c |ime(NULL|);..whil|
|000045d0| 65 28 28 68 6f 73 74 5f | 73 70 65 63 20 3d 20 67 |e((host_|spec = g|
|000045e0| 72 61 62 5f 6e 65 78 74 | 5f 68 6f 73 74 5f 73 70 |rab_next|_host_sp|
|000045f0| 65 63 28 69 6e 70 75 74 | 66 64 2c 20 61 72 67 63 |ec(input|fd, argc|
|00004600| 2c 20 66 61 6b 65 61 72 | 67 76 29 29 29 20 7b 0a |, fakear|gv))) {.|
|00004610| 20 20 77 68 69 6c 65 28 | 28 63 75 72 72 65 6e 74 | while(|(current|
|00004620| 68 73 20 3d 20 6e 65 78 | 74 68 6f 73 74 28 68 6f |hs = nex|thost(ho|
|00004630| 73 74 5f 73 70 65 63 2c | 20 35 30 30 2c 20 6f 2e |st_spec,| 500, o.|
|00004640| 70 74 69 6d 65 29 29 20 | 26 26 20 63 75 72 72 65 |ptime)) |&& curre|
|00004650| 6e 74 68 73 2d 3e 68 6f | 73 74 2e 73 5f 61 64 64 |nths->ho|st.s_add|
|00004660| 72 29 20 7b 0a 20 20 20 | 20 6e 75 6d 68 6f 73 74 |r) {. | numhost|
|00004670| 73 5f 73 63 61 6e 6e 65 | 64 2b 2b 3b 0a 20 20 20 |s_scanne|d++;. |
|00004680| 20 69 66 20 28 63 75 72 | 72 65 6e 74 68 73 2d 3e | if (cur|renths->|
|00004690| 66 6c 61 67 73 20 26 20 | 48 4f 53 54 5f 55 50 29 |flags & |HOST_UP)|
|000046a0| 20 0a 20 20 20 20 20 20 | 6e 75 6d 68 6f 73 74 73 | . |numhosts|
|000046b0| 5f 75 70 2b 2b 3b 0a 0a | 20 20 20 20 2f 2a 20 20 |_up++;..| /* |
|000046c0| 20 20 70 72 69 6e 74 66 | 28 22 4e 65 78 74 68 6f | printf|("Nextho|
|000046d0| 73 74 28 29 20 72 65 74 | 75 72 6e 65 64 3a 20 25 |st() ret|urned: %|
|000046e0| 73 5c 6e 22 2c 20 69 6e | 65 74 5f 6e 74 6f 61 28 |s\n", in|et_ntoa(|
|000046f0| 63 75 72 72 65 6e 74 68 | 73 2d 3e 68 6f 73 74 29 |currenth|s->host)|
|00004700| 29 3b 2a 2f 0a 20 20 20 | 20 74 61 72 67 65 74 20 |);*/. | target |
|00004710| 3d 20 4e 55 4c 4c 3b 0a | 20 20 20 20 69 66 20 28 |= NULL;.| if (|
|00004720| 28 28 63 75 72 72 65 6e | 74 68 73 2d 3e 66 6c 61 |((curren|ths->fla|
|00004730| 67 73 20 26 20 48 4f 53 | 54 5f 55 50 29 20 7c 7c |gs & HOS|T_UP) |||
|00004740| 20 72 65 73 6f 6c 76 65 | 5f 61 6c 6c 29 20 26 26 | resolve|_all) &&|
|00004750| 20 21 6f 2e 6e 6f 72 65 | 73 6f 6c 76 65 29 0a 20 | !o.nore|solve). |
|00004760| 20 20 20 20 20 74 61 72 | 67 65 74 20 3d 20 67 65 | tar|get = ge|
|00004770| 74 68 6f 73 74 62 79 61 | 64 64 72 28 28 63 68 61 |thostbya|ddr((cha|
|00004780| 72 20 2a 29 20 26 63 75 | 72 72 65 6e 74 68 73 2d |r *) &cu|rrenths-|
|00004790| 3e 68 6f 73 74 2c 20 34 | 2c 20 41 46 5f 49 4e 45 |>host, 4|, AF_INE|
|000047a0| 54 29 3b 0a 20 20 20 20 | 69 66 20 28 74 61 72 67 |T);. |if (targ|
|000047b0| 65 74 29 20 7b 0a 20 20 | 20 20 20 20 63 75 72 72 |et) {. | curr|
|000047c0| 65 6e 74 68 73 2d 3e 6e | 61 6d 65 20 3d 20 73 74 |enths->n|ame = st|
|000047d0| 72 64 75 70 28 74 61 72 | 67 65 74 2d 3e 68 5f 6e |rdup(tar|get->h_n|
|000047e0| 61 6d 65 29 3b 0a 20 20 | 20 20 7d 0a 20 20 20 20 |ame);. | }. |
|000047f0| 65 6c 73 65 20 7b 0a 20 | 20 20 20 20 20 63 75 72 |else {. | cur|
|00004800| 72 65 6e 74 68 73 2d 3e | 6e 61 6d 65 20 3d 20 65 |renths->|name = e|
|00004810| 6d 70 74 79 73 74 72 69 | 6e 67 3b 0a 20 20 20 20 |mptystri|ng;. |
|00004820| 7d 0a 0a 20 20 20 20 69 | 66 20 28 6f 2e 73 6f 75 |}.. i|f (o.sou|
|00004830| 72 63 65 29 20 6d 65 6d | 63 70 79 28 26 63 75 72 |rce) mem|cpy(&cur|
|00004840| 72 65 6e 74 68 73 2d 3e | 73 6f 75 72 63 65 5f 69 |renths->|source_i|
|00004850| 70 2c 20 6f 2e 73 6f 75 | 72 63 65 2c 20 73 69 7a |p, o.sou|rce, siz|
|00004860| 65 6f 66 28 73 74 72 75 | 63 74 20 69 6e 5f 61 64 |eof(stru|ct in_ad|
|00004870| 64 72 29 29 3b 0a 69 66 | 20 28 21 6f 2e 70 69 6e |dr));.if| (!o.pin|
|00004880| 67 73 63 61 6e 29 20 7b | 0a 20 20 69 66 20 28 6f |gscan) {|. if (o|
|00004890| 2e 70 69 6e 67 74 79 70 | 65 20 21 3d 20 50 49 4e |.pingtyp|e != PIN|
|000048a0| 47 54 59 50 45 5f 4e 4f | 4e 45 20 26 26 20 28 63 |GTYPE_NO|NE && (c|
|000048b0| 75 72 72 65 6e 74 68 73 | 2d 3e 66 6c 61 67 73 20 |urrenths|->flags |
|000048c0| 26 20 48 4f 53 54 5f 55 | 50 29 20 26 26 20 28 6f |& HOST_U|P) && (o|
|000048d0| 2e 76 65 72 62 6f 73 65 | 20 7c 7c 20 6f 2e 64 65 |.verbose| || o.de|
|000048e0| 62 75 67 67 69 6e 67 29 | 29 20 0a 20 20 20 20 66 |bugging)|) . f|
|000048f0| 70 72 69 6e 74 66 28 6f | 2e 6e 6d 61 70 5f 73 74 |printf(o|.nmap_st|
|00004900| 64 6f 75 74 2c 20 22 48 | 6f 73 74 20 25 73 20 28 |dout, "H|ost %s (|
|00004910| 25 73 29 20 61 70 70 65 | 61 72 73 20 74 6f 20 62 |%s) appe|ars to b|
|00004920| 65 20 75 70 20 2e 2e 2e | 20 67 6f 6f 64 2e 5c 6e |e up ...| good.\n|
|00004930| 22 2c 20 63 75 72 72 65 | 6e 74 68 73 2d 3e 6e 61 |", curre|nths->na|
|00004940| 6d 65 2c 20 69 6e 65 74 | 5f 6e 74 6f 61 28 63 75 |me, inet|_ntoa(cu|
|00004950| 72 72 65 6e 74 68 73 2d | 3e 68 6f 73 74 29 29 3b |rrenths-|>host));|
|00004960| 20 20 20 20 0a 20 20 65 | 6c 73 65 20 69 66 20 28 | . e|lse if (|
|00004970| 6f 2e 76 65 72 62 6f 73 | 65 20 26 26 20 6f 2e 70 |o.verbos|e && o.p|
|00004980| 69 6e 67 74 79 70 65 20 | 21 3d 20 50 49 4e 47 54 |ingtype |!= PINGT|
|00004990| 59 50 45 5f 4e 4f 4e 45 | 20 26 26 20 21 28 63 75 |YPE_NONE| && !(cu|
|000049a0| 72 72 65 6e 74 68 73 2d | 3e 66 6c 61 67 73 20 26 |rrenths-|>flags &|
|000049b0| 20 48 4f 53 54 5f 55 50 | 29 29 20 7b 20 20 0a 20 | HOST_UP|)) { . |
|000049c0| 20 20 20 69 66 20 28 72 | 65 73 6f 6c 76 65 5f 61 | if (r|esolve_a|
|000049d0| 6c 6c 29 0a 20 20 20 20 | 20 20 6e 6d 61 70 5f 6c |ll). | nmap_l|
|000049e0| 6f 67 28 22 48 6f 73 74 | 20 25 73 20 28 25 73 29 |og("Host| %s (%s)|
|000049f0| 20 61 70 70 65 61 72 73 | 20 74 6f 20 62 65 20 64 | appears| to be d|
|00004a00| 6f 77 6e 2c 20 73 6b 69 | 70 70 69 6e 67 20 69 74 |own, ski|pping it|
|00004a10| 2e 5c 6e 22 2c 20 63 75 | 72 72 65 6e 74 68 73 2d |.\n", cu|rrenths-|
|00004a20| 3e 6e 61 6d 65 2c 20 69 | 6e 65 74 5f 6e 74 6f 61 |>name, i|net_ntoa|
|00004a30| 28 63 75 72 72 65 6e 74 | 68 73 2d 3e 68 6f 73 74 |(current|hs->host|
|00004a40| 29 29 3b 0a 20 20 20 20 | 65 6c 73 65 20 66 70 72 |));. |else fpr|
|00004a50| 69 6e 74 66 28 6f 2e 6e | 6d 61 70 5f 73 74 64 6f |intf(o.n|map_stdo|
|00004a60| 75 74 2c 20 22 48 6f 73 | 74 20 25 73 20 28 25 73 |ut, "Hos|t %s (%s|
|00004a70| 29 20 61 70 70 65 61 72 | 73 20 74 6f 20 62 65 20 |) appear|s to be |
|00004a80| 64 6f 77 6e 2c 20 73 6b | 69 70 70 69 6e 67 20 69 |down, sk|ipping i|
|00004a90| 74 2e 5c 6e 22 2c 20 63 | 75 72 72 65 6e 74 68 73 |t.\n", c|urrenths|
|00004aa0| 2d 3e 6e 61 6d 65 2c 20 | 69 6e 65 74 5f 6e 74 6f |->name, |inet_nto|
|00004ab0| 61 28 63 75 72 72 65 6e | 74 68 73 2d 3e 68 6f 73 |a(curren|ths->hos|
|00004ac0| 74 29 29 3b 0a 20 20 7d | 0a 0a 7d 0a 65 6c 73 65 |t));. }|..}.else|
|00004ad0| 20 7b 0a 20 20 69 66 20 | 28 63 75 72 72 65 6e 74 | {. if |(current|
|00004ae0| 68 73 2d 3e 66 6c 61 67 | 73 20 26 20 48 4f 53 54 |hs->flag|s & HOST|
|00004af0| 5f 55 50 29 20 7b 20 20 | 0a 20 20 20 20 6e 6d 61 |_UP) { |. nma|
|00004b00| 70 5f 6c 6f 67 28 22 48 | 6f 73 74 20 25 73 20 28 |p_log("H|ost %s (|
|00004b10| 25 73 29 20 61 70 70 65 | 61 72 73 20 74 6f 20 62 |%s) appe|ars to b|
|00004b20| 65 20 75 70 2e 5c 6e 22 | 2c 20 63 75 72 72 65 6e |e up.\n"|, curren|
|00004b30| 74 68 73 2d 3e 6e 61 6d | 65 2c 20 69 6e 65 74 5f |ths->nam|e, inet_|
|00004b40| 6e 74 6f 61 28 63 75 72 | 72 65 6e 74 68 73 2d 3e |ntoa(cur|renths->|
|00004b50| 68 6f 73 74 29 29 3b 20 | 20 20 20 0a 20 20 20 20 |host)); | . |
|00004b60| 6e 6d 61 70 5f 6d 61 63 | 68 69 6e 65 5f 6c 6f 67 |nmap_mac|hine_log|
|00004b70| 28 22 48 6f 73 74 3a 20 | 25 73 20 28 25 73 29 5c |("Host: |%s (%s)\|
|00004b80| 74 53 74 61 74 75 73 3a | 20 55 70 5c 6e 22 2c 20 |tStatus:| Up\n", |
|00004b90| 69 6e 65 74 5f 6e 74 6f | 61 28 63 75 72 72 65 6e |inet_nto|a(curren|
|00004ba0| 74 68 73 2d 3e 68 6f 73 | 74 29 2c 20 63 75 72 72 |ths->hos|t), curr|
|00004bb0| 65 6e 74 68 73 2d 3e 6e | 61 6d 65 29 3b 0a 20 20 |enths->n|ame);. |
|00004bc0| 7d 0a 20 20 65 6c 73 65 | 20 0a 20 20 20 20 69 66 |}. else| . if|
|00004bd0| 20 28 6f 2e 76 65 72 62 | 6f 73 65 20 7c 7c 20 6f | (o.verb|ose || o|
|00004be0| 2e 64 65 62 75 67 67 69 | 6e 67 20 7c 7c 20 72 65 |.debuggi|ng || re|
|00004bf0| 73 6f 6c 76 65 5f 61 6c | 6c 29 20 7b 20 20 20 20 |solve_al|l) { |
|00004c00| 0a 20 20 20 20 20 20 69 | 66 20 28 72 65 73 6f 6c |. i|f (resol|
|00004c10| 76 65 5f 61 6c 6c 29 0a | 09 6e 6d 61 70 5f 6c 6f |ve_all).|.nmap_lo|
|00004c20| 67 28 22 48 6f 73 74 20 | 25 73 20 28 25 73 29 20 |g("Host |%s (%s) |
|00004c30| 61 70 70 65 61 72 73 20 | 74 6f 20 62 65 20 64 6f |appears |to be do|
|00004c40| 77 6e 2e 5c 6e 22 2c 20 | 63 75 72 72 65 6e 74 68 |wn.\n", |currenth|
|00004c50| 73 2d 3e 6e 61 6d 65 2c | 20 69 6e 65 74 5f 6e 74 |s->name,| inet_nt|
|00004c60| 6f 61 28 63 75 72 72 65 | 6e 74 68 73 2d 3e 68 6f |oa(curre|nths->ho|
|00004c70| 73 74 29 29 3b 0a 20 20 | 20 20 20 20 65 6c 73 65 |st));. | else|
|00004c80| 20 66 70 72 69 6e 74 66 | 28 6f 2e 6e 6d 61 70 5f | fprintf|(o.nmap_|
|00004c90| 73 74 64 6f 75 74 2c 20 | 22 48 6f 73 74 20 25 73 |stdout, |"Host %s|
|00004ca0| 20 28 25 73 29 20 61 70 | 70 65 61 72 73 20 74 6f | (%s) ap|pears to|
|00004cb0| 20 62 65 20 64 6f 77 6e | 2e 5c 6e 22 2c 20 63 75 | be down|.\n", cu|
|00004cc0| 72 72 65 6e 74 68 73 2d | 3e 6e 61 6d 65 2c 20 69 |rrenths-|>name, i|
|00004cd0| 6e 65 74 5f 6e 74 6f 61 | 28 63 75 72 72 65 6e 74 |net_ntoa|(current|
|00004ce0| 68 73 2d 3e 68 6f 73 74 | 29 29 3b 0a 20 20 20 20 |hs->host|));. |
|00004cf0| 7d 0a 7d 0a 0a 20 69 66 | 20 28 63 75 72 72 65 6e |}.}.. if| (curren|
|00004d00| 74 68 73 2d 3e 77 69 65 | 72 64 5f 72 65 73 70 6f |ths->wie|rd_respo|
|00004d10| 6e 73 65 73 29 20 7b 20 | 20 0a 20 20 20 6e 6d 61 |nses) { | . nma|
|00004d20| 70 5f 6c 6f 67 28 22 48 | 6f 73 74 20 20 25 73 20 |p_log("H|ost %s |
|00004d30| 28 25 73 29 20 73 65 65 | 6d 73 20 74 6f 20 62 65 |(%s) see|ms to be|
|00004d40| 20 61 20 73 75 62 6e 65 | 74 20 62 72 6f 61 64 63 | a subne|t broadc|
|00004d50| 61 73 74 20 61 64 64 72 | 65 73 73 20 28 72 65 74 |ast addr|ess (ret|
|00004d60| 75 72 6e 65 64 20 25 64 | 20 65 78 74 72 61 20 70 |urned %d| extra p|
|00004d70| 69 6e 67 73 29 2e 20 20 | 53 6b 69 70 70 69 6e 67 |ings). |Skipping|
|00004d80| 20 68 6f 73 74 2e 5c 6e | 22 2c 20 20 63 75 72 72 | host.\n|", curr|
|00004d90| 65 6e 74 68 73 2d 3e 6e | 61 6d 65 2c 20 69 6e 65 |enths->n|ame, ine|
|00004da0| 74 5f 6e 74 6f 61 28 63 | 75 72 72 65 6e 74 68 73 |t_ntoa(c|urrenths|
|00004db0| 2d 3e 68 6f 73 74 29 2c | 20 63 75 72 72 65 6e 74 |->host),| current|
|00004dc0| 68 73 2d 3e 77 69 65 72 | 64 5f 72 65 73 70 6f 6e |hs->wier|d_respon|
|00004dd0| 73 65 73 29 3b 0a 20 20 | 20 6e 6d 61 70 5f 6d 61 |ses);. | nmap_ma|
|00004de0| 63 68 69 6e 65 5f 6c 6f | 67 28 22 48 6f 73 74 3a |chine_lo|g("Host:|
|00004df0| 20 25 73 20 28 25 73 29 | 5c 74 53 74 61 74 75 73 | %s (%s)|\tStatus|
|00004e00| 3a 20 53 6d 75 72 66 20 | 28 25 64 20 72 65 73 70 |: Smurf |(%d resp|
|00004e10| 6f 6e 73 65 73 29 5c 6e | 22 2c 20 20 69 6e 65 74 |onses)\n|", inet|
|00004e20| 5f 6e 74 6f 61 28 63 75 | 72 72 65 6e 74 68 73 2d |_ntoa(cu|rrenths-|
|00004e30| 3e 68 6f 73 74 29 2c 20 | 63 75 72 72 65 6e 74 68 |>host), |currenth|
|00004e40| 73 2d 3e 6e 61 6d 65 2c | 20 63 75 72 72 65 6e 74 |s->name,| current|
|00004e50| 68 73 2d 3e 77 69 65 72 | 64 5f 72 65 73 70 6f 6e |hs->wier|d_respon|
|00004e60| 73 65 73 29 3b 0a 20 7d | 0a 20 0a 20 2f 2a 20 54 |ses);. }|. . /* T|
|00004e70| 68 65 20 21 63 75 72 72 | 65 6e 74 68 73 2d 3e 77 |he !curr|enths->w|
|00004e80| 69 65 72 64 5f 72 65 73 | 70 6f 6e 73 65 73 20 77 |ierd_res|ponses w|
|00004e90| 61 73 20 63 6f 6d 6d 65 | 6e 74 65 64 20 6f 75 74 |as comme|nted out|
|00004ea0| 20 61 66 74 65 72 20 49 | 20 66 6f 75 6e 64 0a 20 | after I| found. |
|00004eb0| 20 20 20 61 20 73 6d 75 | 72 66 20 61 64 64 72 65 | a smu|rf addre|
|00004ec0| 73 73 20 77 68 69 63 68 | 20 44 49 44 20 61 6c 6c |ss which| DID all|
|00004ed0| 6f 77 20 70 6f 72 74 20 | 73 63 61 6e 6e 69 6e 6e |ow port |scanninn|
|00004ee0| 67 20 61 6e 64 20 79 6f | 75 20 63 6f 75 6c 64 20 |g and yo|u could |
|00004ef0| 65 76 65 6e 0a 20 20 20 | 20 74 65 6c 6e 65 74 74 |even. | telnett|
|00004f00| 68 65 72 65 2e 20 20 77 | 69 65 72 64 20 3a 30 20 |here. w|ierd :0 |
|00004f10| 2a 2f 0a 20 69 66 20 28 | 63 75 72 72 65 6e 74 68 |*/. if (|currenth|
|00004f20| 73 2d 3e 66 6c 61 67 73 | 20 26 20 48 4f 53 54 5f |s->flags| & HOST_|
|00004f30| 55 50 20 2f 2a 20 26 26 | 20 21 63 75 72 72 65 6e |UP /* &&| !curren|
|00004f40| 74 68 73 2d 3e 77 69 65 | 72 64 5f 72 65 73 70 6f |ths->wie|rd_respo|
|00004f50| 6e 73 65 73 2a 2f 20 26 | 26 0a 20 20 20 20 20 21 |nses*/ &|&. !|
|00004f60| 6f 2e 70 69 6e 67 73 63 | 61 6e 29 20 7b 0a 20 20 |o.pingsc|an) {. |
|00004f70| 20 0a 20 20 20 69 66 20 | 28 63 75 72 72 65 6e 74 | . if |(current|
|00004f80| 68 73 2d 3e 66 6c 61 67 | 73 20 26 20 48 4f 53 54 |hs->flag|s & HOST|
|00004f90| 5f 55 50 20 26 26 20 21 | 63 75 72 72 65 6e 74 68 |_UP && !|currenth|
|00004fa0| 73 2d 3e 73 6f 75 72 63 | 65 5f 69 70 2e 73 5f 61 |s->sourc|e_ip.s_a|
|00004fb0| 64 64 72 20 26 26 20 28 | 20 6f 2e 73 79 6e 73 63 |ddr && (| o.synsc|
|00004fc0| 61 6e 20 7c 7c 20 6f 2e | 66 69 6e 73 63 61 6e 20 |an || o.|finscan |
|00004fd0| 7c 7c 20 6f 2e 6d 61 69 | 6d 6f 6e 73 63 61 6e 20 ||| o.mai|monscan |
|00004fe0| 7c 7c 20 6f 2e 75 64 70 | 73 63 61 6e 20 7c 7c 20 ||| o.udp|scan || |
|00004ff0| 6f 2e 6e 75 6c 6c 73 63 | 61 6e 20 7c 7c 20 6f 2e |o.nullsc|an || o.|
|00005000| 78 6d 61 73 73 63 61 6e | 29 29 20 7b 0a 20 20 20 |xmasscan|)) {. |
|00005010| 20 20 69 66 20 28 67 65 | 74 68 6f 73 74 6e 61 6d | if (ge|thostnam|
|00005020| 65 28 6d 79 6e 61 6d 65 | 2c 20 4d 41 58 48 4f 53 |e(myname|, MAXHOS|
|00005030| 54 4e 41 4d 45 4c 45 4e | 29 20 7c 7c 20 0a 09 20 |TNAMELEN|) || .. |
|00005040| 21 28 74 61 72 67 65 74 | 20 3d 20 67 65 74 68 6f |!(target| = getho|
|00005050| 73 74 62 79 6e 61 6d 65 | 28 6d 79 6e 61 6d 65 29 |stbyname|(myname)|
|00005060| 29 29 0a 20 20 20 20 20 | 20 20 66 61 74 61 6c 28 |)). | fatal(|
|00005070| 22 43 61 6e 6e 6f 74 20 | 67 65 74 20 68 6f 73 74 |"Cannot |get host|
|00005080| 6e 61 6d 65 21 20 20 54 | 72 79 20 75 73 69 6e 67 |name! T|ry using|
|00005090| 20 2d 53 20 3c 6d 79 5f | 49 50 5f 61 64 64 72 65 | -S <my_|IP_addre|
|000050a0| 73 73 3e 20 6f 72 20 2d | 65 20 3c 69 6e 74 65 72 |ss> or -|e <inter|
|000050b0| 66 61 63 65 20 74 6f 20 | 73 63 61 6e 20 74 68 72 |face to |scan thr|
|000050c0| 6f 75 67 68 3e 5c 6e 22 | 29 3b 20 0a 20 20 20 20 |ough>\n"|); . |
|000050d0| 20 6d 65 6d 63 70 79 28 | 26 63 75 72 72 65 6e 74 | memcpy(|¤t|
|000050e0| 68 73 2d 3e 73 6f 75 72 | 63 65 5f 69 70 2c 20 74 |hs->sour|ce_ip, t|
|000050f0| 61 72 67 65 74 2d 3e 68 | 5f 61 64 64 72 5f 6c 69 |arget->h|_addr_li|
|00005100| 73 74 5b 30 5d 2c 20 73 | 69 7a 65 6f 66 28 73 74 |st[0], s|izeof(st|
|00005110| 72 75 63 74 20 69 6e 5f | 61 64 64 72 29 29 3b 0a |ruct in_|addr));.|
|00005120| 20 20 20 20 20 69 66 20 | 28 21 20 73 6f 75 72 63 | if |(! sourc|
|00005130| 65 61 64 64 72 77 61 72 | 6e 69 6e 67 29 20 7b 0a |eaddrwar|ning) {.|
|00005140| 20 20 20 20 20 20 20 66 | 70 72 69 6e 74 66 28 73 | f|printf(s|
|00005150| 74 64 65 72 72 2c 20 22 | 57 41 52 4e 49 4e 47 3a |tderr, "|WARNING:|
|00005160| 20 20 57 65 20 63 6f 75 | 6c 64 20 6e 6f 74 20 64 | We cou|ld not d|
|00005170| 65 74 65 72 6d 69 6e 65 | 20 66 6f 72 20 73 75 72 |etermine| for sur|
|00005180| 65 20 77 68 69 63 68 20 | 69 6e 74 65 72 66 61 63 |e which |interfac|
|00005190| 65 20 74 6f 20 75 73 65 | 2c 20 73 6f 20 77 65 20 |e to use|, so we |
|000051a0| 61 72 65 20 67 75 65 73 | 73 69 6e 67 20 25 73 20 |are gues|sing %s |
|000051b0| 2e 20 20 49 66 20 74 68 | 69 73 20 69 73 20 77 72 |. If th|is is wr|
|000051c0| 6f 6e 67 2c 20 75 73 65 | 20 2d 53 20 3c 6d 79 5f |ong, use| -S <my_|
|000051d0| 49 50 5f 61 64 64 72 65 | 73 73 3e 2e 5c 6e 22 2c |IP_addre|ss>.\n",|
|000051e0| 20 69 6e 65 74 5f 6e 74 | 6f 61 28 63 75 72 72 65 | inet_nt|oa(curre|
|000051f0| 6e 74 68 73 2d 3e 73 6f | 75 72 63 65 5f 69 70 29 |nths->so|urce_ip)|
|00005200| 29 3b 0a 20 20 20 20 20 | 20 20 73 6f 75 72 63 65 |);. | source|
|00005210| 61 64 64 72 77 61 72 6e | 69 6e 67 20 3d 20 31 3b |addrwarn|ing = 1;|
|00005220| 0a 20 20 20 20 20 7d 0a | 20 20 20 7d 0a 20 20 20 |. }.| }. |
|00005230| 0a 20 20 20 2f 2a 20 46 | 69 67 75 72 65 20 6f 75 |. /* F|igure ou|
|00005240| 74 20 77 68 61 74 20 6c | 69 6e 6b 2d 6c 61 79 65 |t what l|ink-laye|
|00005250| 72 20 64 65 76 69 63 65 | 20 28 69 6e 74 65 72 66 |r device| (interf|
|00005260| 61 63 65 29 20 74 6f 20 | 75 73 65 20 28 69 65 20 |ace) to |use (ie |
|00005270| 65 74 68 30 2c 20 70 70 | 70 30 2c 20 65 74 63 29 |eth0, pp|p0, etc)|
|00005280| 20 2a 2f 0a 20 20 20 69 | 66 20 28 21 2a 63 75 72 | */. i|f (!*cur|
|00005290| 72 65 6e 74 68 73 2d 3e | 64 65 76 69 63 65 20 26 |renths->|device &|
|000052a0| 26 20 63 75 72 72 65 6e | 74 68 73 2d 3e 66 6c 61 |& curren|ths->fla|
|000052b0| 67 73 20 26 20 48 4f 53 | 54 5f 55 50 20 26 26 20 |gs & HOS|T_UP && |
|000052c0| 28 6f 2e 6e 75 6c 6c 73 | 63 61 6e 20 7c 7c 20 6f |(o.nulls|can || o|
|000052d0| 2e 78 6d 61 73 73 63 61 | 6e 20 7c 7c 20 6f 2e 75 |.xmassca|n || o.u|
|000052e0| 64 70 73 63 61 6e 20 7c | 7c 20 6f 2e 66 69 6e 73 |dpscan ||| o.fins|
|000052f0| 63 61 6e 20 7c 7c 20 6f | 2e 6d 61 69 6d 6f 6e 73 |can || o|.maimons|
|00005300| 63 61 6e 20 7c 7c 20 20 | 6f 2e 73 79 6e 73 63 61 |can || |o.synsca|
|00005310| 6e 20 7c 7c 20 6f 2e 6f | 73 73 63 61 6e 29 20 26 |n || o.o|sscan) &|
|00005320| 26 20 28 69 70 61 64 64 | 72 32 64 65 76 6e 61 6d |& (ipadd|r2devnam|
|00005330| 65 28 20 63 75 72 72 65 | 6e 74 68 73 2d 3e 64 65 |e( curre|nths->de|
|00005340| 76 69 63 65 2c 20 26 63 | 75 72 72 65 6e 74 68 73 |vice, &c|urrenths|
|00005350| 2d 3e 73 6f 75 72 63 65 | 5f 69 70 29 20 21 3d 20 |->source|_ip) != |
|00005360| 30 29 29 0a 20 20 20 20 | 20 66 61 74 61 6c 28 22 |0)). | fatal("|
|00005370| 43 6f 75 6c 64 20 6e 6f | 74 20 66 69 67 75 72 65 |Could no|t figure|
|00005380| 20 6f 75 74 20 77 68 61 | 74 20 64 65 76 69 63 65 | out wha|t device|
|00005390| 20 74 6f 20 73 65 6e 64 | 20 74 68 65 20 70 61 63 | to send| the pac|
|000053a0| 6b 65 74 20 6f 75 74 20 | 6f 6e 21 20 20 59 6f 75 |ket out |on! You|
|000053b0| 20 6d 69 67 68 74 20 70 | 6f 73 73 69 62 6c 79 20 | might p|ossibly |
|000053c0| 77 61 6e 74 20 74 6f 20 | 74 72 79 20 2d 53 20 28 |want to |try -S (|
|000053d0| 62 75 74 20 74 68 69 73 | 20 69 73 20 70 72 6f 62 |but this| is prob|
|000053e0| 61 62 6c 79 20 61 20 62 | 69 67 67 65 72 20 70 72 |ably a b|igger pr|
|000053f0| 6f 62 6c 65 6d 29 2e 20 | 20 49 66 20 79 6f 75 20 |oblem). | If you |
|00005400| 61 72 65 20 74 72 79 69 | 6e 67 20 74 6f 20 73 70 |are tryi|ng to sp|
|00005410| 30 30 66 20 74 68 65 20 | 73 6f 75 72 63 65 20 6f |00f the |source o|
|00005420| 66 20 61 20 53 59 4e 2f | 46 49 4e 20 73 63 61 6e |f a SYN/|FIN scan|
|00005430| 20 77 69 74 68 20 2d 53 | 20 3c 66 61 6b 65 69 70 | with -S| <fakeip|
|00005440| 3e 2c 20 74 68 65 6e 20 | 79 6f 75 20 6d 75 73 74 |>, then |you must|
|00005450| 20 75 73 65 20 2d 65 20 | 65 74 68 30 20 28 6f 72 | use -e |eth0 (or|
|00005460| 20 6f 74 68 65 72 20 64 | 65 76 69 63 65 6e 61 6d | other d|evicenam|
|00005470| 65 29 20 74 6f 20 74 65 | 6c 6c 20 75 73 20 77 68 |e) to te|ll us wh|
|00005480| 61 74 20 69 6e 74 65 72 | 66 61 63 65 20 74 6f 20 |at inter|face to |
|00005490| 75 73 65 2e 5c 6e 22 29 | 3b 0a 20 20 20 2f 2a 20 |use.\n")|;. /* |
|000054a0| 53 65 74 20 75 70 20 74 | 68 65 20 64 65 63 6f 79 |Set up t|he decoy|
|000054b0| 20 2a 2f 0a 20 20 20 6f | 2e 64 65 63 6f 79 73 5b | */. o|.decoys[|
|000054c0| 6f 2e 64 65 63 6f 79 74 | 75 72 6e 5d 20 3d 20 63 |o.decoyt|urn] = c|
|000054d0| 75 72 72 65 6e 74 68 73 | 2d 3e 73 6f 75 72 63 65 |urrenths|->source|
|000054e0| 5f 69 70 3b 0a 20 20 20 | 0a 20 20 20 2f 2a 20 54 |_ip;. |. /* T|
|000054f0| 69 6d 65 20 66 6f 72 20 | 73 6f 6d 65 20 61 63 74 |ime for |some act|
|00005500| 75 61 6c 20 73 63 61 6e | 6e 69 6e 67 21 20 2a 2f |ual scan|ning! */|
|00005510| 20 20 20 20 0a 20 20 20 | 0a 20 20 20 0a 20 20 20 | . |. . |
|00005520| 69 66 20 28 6f 2e 73 79 | 6e 73 63 61 6e 29 20 70 |if (o.sy|nscan) p|
|00005530| 6f 73 5f 73 63 61 6e 28 | 63 75 72 72 65 6e 74 68 |os_scan(|currenth|
|00005540| 73 2c 20 70 6f 72 74 73 | 2c 20 53 59 4e 5f 53 43 |s, ports|, SYN_SC|
|00005550| 41 4e 29 3b 0a 20 20 20 | 69 66 20 28 6f 2e 63 6f |AN);. |if (o.co|
|00005560| 6e 6e 65 63 74 73 63 61 | 6e 29 20 70 6f 73 5f 73 |nnectsca|n) pos_s|
|00005570| 63 61 6e 28 63 75 72 72 | 65 6e 74 68 73 2c 20 70 |can(curr|enths, p|
|00005580| 6f 72 74 73 2c 20 43 4f | 4e 4e 45 43 54 5f 53 43 |orts, CO|NNECT_SC|
|00005590| 41 4e 29 3b 20 20 20 20 | 20 20 0a 20 20 20 0a 20 |AN); | . . |
|000055a0| 20 20 69 66 20 28 6f 2e | 66 69 6e 73 63 61 6e 29 | if (o.|finscan)|
|000055b0| 20 73 75 70 65 72 5f 73 | 63 61 6e 28 63 75 72 72 | super_s|can(curr|
|000055c0| 65 6e 74 68 73 2c 20 70 | 6f 72 74 73 2c 20 46 49 |enths, p|orts, FI|
|000055d0| 4e 5f 53 43 41 4e 29 3b | 0a 20 20 20 69 66 20 28 |N_SCAN);|. if (|
|000055e0| 6f 2e 78 6d 61 73 73 63 | 61 6e 29 20 73 75 70 65 |o.xmassc|an) supe|
|000055f0| 72 5f 73 63 61 6e 28 63 | 75 72 72 65 6e 74 68 73 |r_scan(c|urrenths|
|00005600| 2c 20 70 6f 72 74 73 2c | 20 58 4d 41 53 5f 53 43 |, ports,| XMAS_SC|
|00005610| 41 4e 29 3b 0a 20 20 20 | 69 66 20 28 6f 2e 6e 75 |AN);. |if (o.nu|
|00005620| 6c 6c 73 63 61 6e 29 20 | 73 75 70 65 72 5f 73 63 |llscan) |super_sc|
|00005630| 61 6e 28 63 75 72 72 65 | 6e 74 68 73 2c 20 70 6f |an(curre|nths, po|
|00005640| 72 74 73 2c 20 4e 55 4c | 4c 5f 53 43 41 4e 29 3b |rts, NUL|L_SCAN);|
|00005650| 0a 20 20 20 69 66 20 28 | 6f 2e 6d 61 69 6d 6f 6e |. if (|o.maimon|
|00005660| 73 63 61 6e 29 20 73 75 | 70 65 72 5f 73 63 61 6e |scan) su|per_scan|
|00005670| 28 63 75 72 72 65 6e 74 | 68 73 2c 20 70 6f 72 74 |(current|hs, port|
|00005680| 73 2c 20 4d 41 49 4d 4f | 4e 5f 53 43 41 4e 29 3b |s, MAIMO|N_SCAN);|
|00005690| 0a 20 20 20 69 66 20 28 | 6f 2e 75 64 70 73 63 61 |. if (|o.udpsca|
|000056a0| 6e 29 20 73 75 70 65 72 | 5f 73 63 61 6e 28 63 75 |n) super|_scan(cu|
|000056b0| 72 72 65 6e 74 68 73 2c | 20 70 6f 72 74 73 2c 20 |rrenths,| ports, |
|000056c0| 55 44 50 5f 53 43 41 4e | 29 3b 0a 20 20 20 0a 20 |UDP_SCAN|);. . |
|000056d0| 20 20 69 66 20 28 6f 2e | 62 6f 75 6e 63 65 73 63 | if (o.|bouncesc|
|000056e0| 61 6e 29 20 7b 0a 20 20 | 20 20 20 69 66 20 28 66 |an) {. | if (f|
|000056f0| 74 70 2e 73 64 20 3c 3d | 20 30 29 20 66 74 70 5f |tp.sd <=| 0) ftp_|
|00005700| 61 6e 6f 6e 5f 63 6f 6e | 6e 65 63 74 28 26 66 74 |anon_con|nect(&ft|
|00005710| 70 29 3b 0a 20 20 20 20 | 20 69 66 20 28 66 74 70 |p);. | if (ftp|
|00005720| 2e 73 64 20 3e 20 30 29 | 20 62 6f 75 6e 63 65 5f |.sd > 0)| bounce_|
|00005730| 73 63 61 6e 28 63 75 72 | 72 65 6e 74 68 73 2c 20 |scan(cur|renths, |
|00005740| 70 6f 72 74 73 2c 20 26 | 66 74 70 29 3b 0a 20 20 |ports, &|ftp);. |
|00005750| 20 7d 0a 20 20 20 0a 20 | 20 20 69 66 20 28 6f 2e | }. . | if (o.|
|00005760| 6f 73 73 63 61 6e 29 20 | 7b 0a 20 20 20 20 20 6f |osscan) |{. o|
|00005770| 73 5f 73 63 61 6e 28 63 | 75 72 72 65 6e 74 68 73 |s_scan(c|urrenths|
|00005780| 29 3b 0a 20 20 20 7d 0a | 20 20 20 0a 20 20 20 69 |);. }.| . i|
|00005790| 66 20 28 21 63 75 72 72 | 65 6e 74 68 73 2d 3e 70 |f (!curr|enths->p|
|000057a0| 6f 72 74 73 20 26 26 20 | 21 6f 2e 70 69 6e 67 73 |orts && |!o.pings|
|000057b0| 63 61 6e 29 20 7b 0a 20 | 20 20 20 20 6e 6d 61 70 |can) {. | nmap|
|000057c0| 5f 6c 6f 67 28 22 4e 6f | 20 70 6f 72 74 73 20 6f |_log("No| ports o|
|000057d0| 70 65 6e 20 66 6f 72 20 | 68 6f 73 74 20 25 73 20 |pen for |host %s |
|000057e0| 28 25 73 29 5c 6e 22 2c | 20 63 75 72 72 65 6e 74 |(%s)\n",| current|
|000057f0| 68 73 2d 3e 6e 61 6d 65 | 2c 0a 09 20 20 20 20 20 |hs->name|,.. |
|00005800| 20 69 6e 65 74 5f 6e 74 | 6f 61 28 63 75 72 72 65 | inet_nt|oa(curre|
|00005810| 6e 74 68 73 2d 3e 68 6f | 73 74 29 29 3b 0a 20 20 |nths->ho|st));. |
|00005820| 20 20 20 6e 6d 61 70 5f | 6d 61 63 68 69 6e 65 5f | nmap_|machine_|
|00005830| 6c 6f 67 28 22 48 6f 73 | 74 3a 20 25 73 20 28 25 |log("Hos|t: %s (%|
|00005840| 73 29 5c 74 53 74 61 74 | 75 73 3a 20 55 70 22 2c |s)\tStat|us: Up",|
|00005850| 20 0a 09 09 20 20 20 20 | 20 20 69 6e 65 74 5f 6e | ... | inet_n|
|00005860| 74 6f 61 28 63 75 72 72 | 65 6e 74 68 73 2d 3e 68 |toa(curr|enths->h|
|00005870| 6f 73 74 29 2c 20 63 75 | 72 72 65 6e 74 68 73 2d |ost), cu|rrenths-|
|00005880| 3e 6e 61 6d 65 29 3b 0a | 20 20 20 7d 0a 20 20 20 |>name);.| }. |
|00005890| 69 66 20 28 63 75 72 72 | 65 6e 74 68 73 2d 3e 70 |if (curr|enths->p|
|000058a0| 6f 72 74 73 29 20 7b 0a | 20 20 20 20 20 6e 6d 61 |orts) {.| nma|
|000058b0| 70 5f 6c 6f 67 28 22 49 | 6e 74 65 72 65 73 74 69 |p_log("I|nteresti|
|000058c0| 6e 67 20 70 6f 72 74 73 | 20 6f 6e 20 25 73 20 28 |ng ports| on %s (|
|000058d0| 25 73 29 3a 5c 6e 22 2c | 20 63 75 72 72 65 6e 74 |%s):\n",| current|
|000058e0| 68 73 2d 3e 6e 61 6d 65 | 2c 20 0a 09 20 20 20 20 |hs->name|, .. |
|000058f0| 20 20 69 6e 65 74 5f 6e | 74 6f 61 28 63 75 72 72 | inet_n|toa(curr|
|00005900| 65 6e 74 68 73 2d 3e 68 | 6f 73 74 29 29 3b 0a 20 |enths->h|ost));. |
|00005910| 20 20 20 20 6e 6d 61 70 | 5f 6d 61 63 68 69 6e 65 | nmap|_machine|
|00005920| 5f 6c 6f 67 28 22 48 6f | 73 74 3a 20 25 73 20 28 |_log("Ho|st: %s (|
|00005930| 25 73 29 22 2c 20 69 6e | 65 74 5f 6e 74 6f 61 28 |%s)", in|et_ntoa(|
|00005940| 63 75 72 72 65 6e 74 68 | 73 2d 3e 68 6f 73 74 29 |currenth|s->host)|
|00005950| 2c 20 0a 09 09 20 20 20 | 20 20 20 63 75 72 72 65 |, ... | curre|
|00005960| 6e 74 68 73 2d 3e 6e 61 | 6d 65 29 3b 0a 20 20 20 |nths->na|me);. |
|00005970| 20 20 69 6e 76 65 72 74 | 66 69 72 65 77 61 6c 6c | invert|firewall|
|00005980| 65 64 28 26 63 75 72 72 | 65 6e 74 68 73 2d 3e 70 |ed(&curr|enths->p|
|00005990| 6f 72 74 73 2c 20 70 6f | 72 74 73 29 3b 0a 20 20 |orts, po|rts);. |
|000059a0| 20 20 20 70 72 69 6e 74 | 61 6e 64 66 72 65 65 70 | print|andfreep|
|000059b0| 6f 72 74 73 28 63 75 72 | 72 65 6e 74 68 73 2d 3e |orts(cur|renths->|
|000059c0| 70 6f 72 74 73 29 3b 0a | 20 20 20 7d 0a 20 20 20 |ports);.| }. |
|000059d0| 69 66 20 28 6f 2e 6f 73 | 73 63 61 6e 29 20 7b 0a |if (o.os|scan) {.|
|000059e0| 20 20 20 20 20 69 66 20 | 28 63 75 72 72 65 6e 74 | if |(current|
|000059f0| 68 73 2d 3e 73 65 71 2e | 72 65 73 70 6f 6e 73 65 |hs->seq.|response|
|00005a00| 73 20 3e 20 33 29 20 7b | 0a 20 20 20 20 20 20 20 |s > 3) {|. |
|00005a10| 6e 6d 61 70 5f 6c 6f 67 | 28 22 25 73 22 2c 20 73 |nmap_log|("%s", s|
|00005a20| 65 71 72 65 70 6f 72 74 | 28 26 28 63 75 72 72 65 |eqreport|(&(curre|
|00005a30| 6e 74 68 73 2d 3e 73 65 | 71 29 29 29 3b 0a 20 20 |nths->se|q)));. |
|00005a40| 20 20 20 20 20 6e 6d 61 | 70 5f 6d 61 63 68 69 6e | nma|p_machin|
|00005a50| 65 5f 6c 6f 67 28 22 5c | 74 53 65 71 20 49 6e 64 |e_log("\|tSeq Ind|
|00005a60| 65 78 3a 20 25 64 22 2c | 20 63 75 72 72 65 6e 74 |ex: %d",| current|
|00005a70| 68 73 2d 3e 73 65 71 2e | 69 6e 64 65 78 29 3b 0a |hs->seq.|index);.|
|00005a80| 20 20 20 20 20 7d 0a 20 | 20 20 20 20 69 66 20 28 | }. | if (|
|00005a90| 63 75 72 72 65 6e 74 68 | 73 2d 3e 46 50 5f 6d 61 |currenth|s->FP_ma|
|00005aa0| 74 63 68 65 73 5b 30 5d | 29 20 7b 0a 20 20 20 20 |tches[0]|) {. |
|00005ab0| 20 20 20 6e 6d 61 70 5f | 6d 61 63 68 69 6e 65 5f | nmap_|machine_|
|00005ac0| 6c 6f 67 28 22 5c 74 4f | 53 3a 20 25 73 22 2c 20 |log("\tO|S: %s", |
|00005ad0| 20 63 75 72 72 65 6e 74 | 68 73 2d 3e 46 50 5f 6d | current|hs->FP_m|
|00005ae0| 61 74 63 68 65 73 5b 30 | 5d 2d 3e 4f 53 5f 6e 61 |atches[0|]->OS_na|
|00005af0| 6d 65 29 3b 0a 20 20 20 | 20 20 20 20 69 20 3d 20 |me);. | i = |
|00005b00| 31 3b 0a 20 20 20 20 20 | 20 20 77 68 69 6c 65 28 |1;. | while(|
|00005b10| 63 75 72 72 65 6e 74 68 | 73 2d 3e 46 50 5f 6d 61 |currenth|s->FP_ma|
|00005b20| 74 63 68 65 73 5b 69 5d | 29 20 7b 0a 09 20 6e 6d |tches[i]|) {.. nm|
|00005b30| 61 70 5f 6d 61 63 68 69 | 6e 65 5f 6c 6f 67 28 22 |ap_machi|ne_log("|
|00005b40| 7c 25 73 22 2c 20 63 75 | 72 72 65 6e 74 68 73 2d ||%s", cu|rrenths-|
|00005b50| 3e 46 50 5f 6d 61 74 63 | 68 65 73 5b 69 5d 2d 3e |>FP_matc|hes[i]->|
|00005b60| 4f 53 5f 6e 61 6d 65 29 | 3b 0a 09 20 69 2b 2b 3b |OS_name)|;.. i++;|
|00005b70| 0a 20 20 20 20 20 20 20 | 7d 0a 20 20 20 20 20 20 |. |}. |
|00005b80| 20 69 66 20 28 21 63 75 | 72 72 65 6e 74 68 73 2d | if (!cu|rrenths-|
|00005b90| 3e 46 50 5f 6d 61 74 63 | 68 65 73 5b 31 5d 29 0a |>FP_matc|hes[1]).|
|00005ba0| 09 20 6e 6d 61 70 5f 6c | 6f 67 28 22 52 65 6d 6f |. nmap_l|og("Remo|
|00005bb0| 74 65 20 6f 70 65 72 61 | 74 69 6e 67 20 73 79 73 |te opera|ting sys|
|00005bc0| 74 65 6d 20 67 75 65 73 | 73 3a 20 25 73 22 2c 20 |tem gues|s: %s", |
|00005bd0| 0a 09 09 20 20 63 75 72 | 72 65 6e 74 68 73 2d 3e |... cur|renths->|
|00005be0| 46 50 5f 6d 61 74 63 68 | 65 73 5b 30 5d 2d 3e 4f |FP_match|es[0]->O|
|00005bf0| 53 5f 6e 61 6d 65 29 3b | 0a 20 20 20 20 20 20 20 |S_name);|. |
|00005c00| 65 6c 73 65 20 20 7b 0a | 09 20 6e 6d 61 70 5f 6c |else {.|. nmap_l|
|00005c10| 6f 67 28 22 52 65 6d 6f | 74 65 20 4f 53 20 67 75 |og("Remo|te OS gu|
|00005c20| 65 73 73 65 73 3a 20 25 | 73 22 2c 20 0a 09 09 20 |esses: %|s", ... |
|00005c30| 20 63 75 72 72 65 6e 74 | 68 73 2d 3e 46 50 5f 6d | current|hs->FP_m|
|00005c40| 61 74 63 68 65 73 5b 30 | 5d 2d 3e 4f 53 5f 6e 61 |atches[0|]->OS_na|
|00005c50| 6d 65 29 3b 0a 09 20 69 | 20 3d 20 31 3b 0a 09 20 |me);.. i| = 1;.. |
|00005c60| 77 68 69 6c 65 28 63 75 | 72 72 65 6e 74 68 73 2d |while(cu|rrenths-|
|00005c70| 3e 46 50 5f 6d 61 74 63 | 68 65 73 5b 69 5d 29 20 |>FP_matc|hes[i]) |
|00005c80| 7b 0a 09 20 20 20 6e 6d | 61 70 5f 6c 6f 67 28 22 |{.. nm|ap_log("|
|00005c90| 2c 20 25 73 22 2c 20 63 | 75 72 72 65 6e 74 68 73 |, %s", c|urrenths|
|00005ca0| 2d 3e 46 50 5f 6d 61 74 | 63 68 65 73 5b 69 5d 2d |->FP_mat|ches[i]-|
|00005cb0| 3e 4f 53 5f 6e 61 6d 65 | 29 3b 0a 09 20 20 20 69 |>OS_name|);.. i|
|00005cc0| 2b 2b 3b 0a 09 20 7d 0a | 20 20 20 20 20 20 20 7d |++;.. }.| }|
|00005cd0| 0a 20 20 20 20 20 20 20 | 6e 6d 61 70 5f 6c 6f 67 |. |nmap_log|
|00005ce0| 28 22 5c 6e 22 29 3b 09 | 20 20 0a 20 20 20 20 20 |("\n");.| . |
|00005cf0| 20 20 69 66 20 28 63 75 | 72 72 65 6e 74 68 73 2d | if (cu|rrenths-|
|00005d00| 3e 67 6f 6f 64 46 50 20 | 3e 3d 20 30 20 26 26 20 |>goodFP |>= 0 && |
|00005d10| 28 6f 2e 64 65 62 75 67 | 67 69 6e 67 20 7c 7c 20 |(o.debug|ging || |
|00005d20| 6f 2e 76 65 72 62 6f 73 | 65 20 3e 20 31 29 29 20 |o.verbos|e > 1)) |
|00005d30| 7b 0a 09 20 6e 6d 61 70 | 5f 6c 6f 67 28 22 4f 53 |{.. nmap|_log("OS|
|00005d40| 20 46 69 6e 67 65 72 70 | 72 69 6e 74 3a 5c 6e 25 | Fingerp|rint:\n%|
|00005d50| 73 5c 6e 22 2c 20 66 70 | 32 61 73 63 69 69 28 63 |s\n", fp|2ascii(c|
|00005d60| 75 72 72 65 6e 74 68 73 | 2d 3e 46 50 73 5b 63 75 |urrenths|->FPs[cu|
|00005d70| 72 72 65 6e 74 68 73 2d | 3e 67 6f 6f 64 46 50 5d |rrenths-|>goodFP]|
|00005d80| 29 29 3b 0a 20 20 20 20 | 20 20 20 7d 0a 20 20 20 |));. | }. |
|00005d90| 20 20 20 20 6e 6d 61 70 | 5f 6c 6f 67 28 22 5c 6e | nmap|_log("\n|
|00005da0| 22 29 3b 0a 20 20 20 20 | 20 7d 20 65 6c 73 65 20 |");. | } else |
|00005db0| 7b 0a 20 20 20 20 20 20 | 20 69 66 20 28 63 75 72 |{. | if (cur|
|00005dc0| 72 65 6e 74 68 73 2d 3e | 67 6f 6f 64 46 50 20 3d |renths->|goodFP =|
|00005dd0| 3d 20 45 4e 4f 4d 41 54 | 43 48 45 53 41 54 41 4c |= ENOMAT|CHESATAL|
|00005de0| 4c 29 20 7b 20 20 20 20 | 20 20 20 0a 09 20 6e 6d |L) { | .. nm|
|00005df0| 61 70 5f 6c 6f 67 28 22 | 4e 6f 20 4f 53 20 6d 61 |ap_log("|No OS ma|
|00005e00| 74 63 68 65 73 20 66 6f | 72 20 68 6f 73 74 20 28 |tches fo|r host (|
|00005e10| 73 65 65 20 68 74 74 70 | 3a 2f 2f 77 77 77 2e 69 |see http|://www.i|
|00005e20| 6e 73 65 63 75 72 65 2e | 6f 72 67 2f 63 67 69 2d |nsecure.|org/cgi-|
|00005e30| 62 69 6e 2f 6e 6d 61 70 | 2d 73 75 62 6d 69 74 2e |bin/nmap|-submit.|
|00005e40| 63 67 69 29 2e 5c 6e 54 | 43 50 2f 49 50 20 66 69 |cgi).\nT|CP/IP fi|
|00005e50| 6e 67 65 72 70 72 69 6e | 74 3a 5c 6e 25 73 5c 6e |ngerprin|t:\n%s\n|
|00005e60| 5c 6e 22 2c 20 6d 65 72 | 67 65 46 50 73 28 63 75 |\n", mer|geFPs(cu|
|00005e70| 72 72 65 6e 74 68 73 2d | 3e 46 50 73 2c 20 63 75 |rrenths-|>FPs, cu|
|00005e80| 72 72 65 6e 74 68 73 2d | 3e 6e 75 6d 46 50 73 29 |rrenths-|>numFPs)|
|00005e90| 29 3b 0a 20 20 20 20 20 | 20 20 7d 20 65 6c 73 65 |);. | } else|
|00005ea0| 20 69 66 20 28 63 75 72 | 72 65 6e 74 68 73 2d 3e | if (cur|renths->|
|00005eb0| 67 6f 6f 64 46 50 20 3d | 3d 20 45 54 4f 4f 4d 41 |goodFP =|= ETOOMA|
|00005ec0| 4e 59 4d 41 54 43 48 45 | 53 29 20 7b 0a 09 20 6e |NYMATCHE|S) {.. n|
|00005ed0| 6d 61 70 5f 6c 6f 67 28 | 22 54 6f 6f 20 6d 61 6e |map_log(|"Too man|
|00005ee0| 79 20 66 69 6e 67 65 72 | 70 72 69 6e 74 73 20 6d |y finger|prints m|
|00005ef0| 61 74 63 68 20 74 68 69 | 73 20 68 6f 73 74 20 66 |atch thi|s host f|
|00005f00| 6f 72 20 6d 65 20 74 6f | 20 67 69 76 65 20 61 6e |or me to| give an|
|00005f10| 20 61 63 63 75 72 61 74 | 65 20 4f 53 20 67 75 65 | accurat|e OS gue|
|00005f20| 73 73 5c 6e 22 29 3b 0a | 09 20 69 66 20 28 6f 2e |ss\n");.|. if (o.|
|00005f30| 64 65 62 75 67 67 69 6e | 67 20 7c 7c 20 6f 2e 76 |debuggin|g || o.v|
|00005f40| 65 72 62 6f 73 65 29 20 | 7b 0a 09 20 20 20 6e 6d |erbose) |{.. nm|
|00005f50| 61 70 5f 6c 6f 67 28 22 | 54 43 50 2f 49 50 20 66 |ap_log("|TCP/IP f|
|00005f60| 69 6e 67 65 72 70 72 69 | 6e 74 3a 5c 6e 25 73 5c |ingerpri|nt:\n%s\|
|00005f70| 6e 5c 6e 22 2c 20 20 6d | 65 72 67 65 46 50 73 28 |n\n", m|ergeFPs(|
|00005f80| 63 75 72 72 65 6e 74 68 | 73 2d 3e 46 50 73 2c 20 |currenth|s->FPs, |
|00005f90| 63 75 72 72 65 6e 74 68 | 73 2d 3e 6e 75 6d 46 50 |currenth|s->numFP|
|00005fa0| 73 29 29 3b 0a 09 20 7d | 0a 20 20 20 20 20 20 20 |s));.. }|. |
|00005fb0| 7d 0a 20 20 20 20 20 7d | 0a 20 20 20 20 20 66 6f |}. }|. fo|
|00005fc0| 72 28 69 3d 30 3b 20 69 | 20 3c 20 63 75 72 72 65 |r(i=0; i| < curre|
|00005fd0| 6e 74 68 73 2d 3e 6e 75 | 6d 46 50 73 3b 20 69 2b |nths->nu|mFPs; i+|
|00005fe0| 2b 29 0a 20 20 20 20 20 | 20 20 66 72 65 65 46 69 |+). | freeFi|
|00005ff0| 6e 67 65 72 50 72 69 6e | 74 28 63 75 72 72 65 6e |ngerPrin|t(curren|
|00006000| 74 68 73 2d 3e 46 50 73 | 5b 69 5d 29 3b 0a 20 20 |ths->FPs|[i]);. |
|00006010| 20 7d 0a 0a 20 20 20 69 | 66 20 28 6f 2e 6d 61 63 | }.. i|f (o.mac|
|00006020| 68 69 6e 65 6c 6f 67 66 | 64 29 20 66 66 6c 75 73 |hinelogf|d) fflus|
|00006030| 68 28 6f 2e 6d 61 63 68 | 69 6e 65 6c 6f 67 66 64 |h(o.mach|inelogfd|
|00006040| 29 3b 0a 20 20 20 69 66 | 20 28 6f 2e 64 65 62 75 |);. if| (o.debu|
|00006050| 67 67 69 6e 67 29 20 66 | 70 72 69 6e 74 66 28 6f |gging) f|printf(o|
|00006060| 2e 6e 6d 61 70 5f 73 74 | 64 6f 75 74 2c 20 22 46 |.nmap_st|dout, "F|
|00006070| 69 6e 61 6c 20 74 69 6d | 65 73 20 66 6f 72 20 68 |inal tim|es for h|
|00006080| 6f 73 74 3a 20 73 72 74 | 74 3a 20 25 64 20 72 74 |ost: srt|t: %d rt|
|00006090| 74 76 61 72 3a 20 25 64 | 20 20 74 6f 3a 20 25 64 |tvar: %d| to: %d|
|000060a0| 5c 6e 22 2c 20 63 75 72 | 72 65 6e 74 68 73 2d 3e |\n", cur|renths->|
|000060b0| 74 6f 2e 73 72 74 74 2c | 20 63 75 72 72 65 6e 74 |to.srtt,| current|
|000060c0| 68 73 2d 3e 74 6f 2e 72 | 74 74 76 61 72 2c 20 63 |hs->to.r|ttvar, c|
|000060d0| 75 72 72 65 6e 74 68 73 | 2d 3e 74 6f 2e 74 69 6d |urrenths|->to.tim|
|000060e0| 65 6f 75 74 29 3b 0a 20 | 20 20 6e 6d 61 70 5f 6d |eout);. | nmap_m|
|000060f0| 61 63 68 69 6e 65 5f 6c | 6f 67 28 22 5c 6e 22 29 |achine_l|og("\n")|
|00006100| 3b 0a 20 7d 0a 20 66 66 | 6c 75 73 68 28 73 74 64 |;. }. ff|lush(std|
|00006110| 6f 75 74 29 3b 0a 20 69 | 66 20 28 6f 2e 6d 61 63 |out);. i|f (o.mac|
|00006120| 68 69 6e 65 6c 6f 67 66 | 64 29 20 66 66 6c 75 73 |hinelogf|d) fflus|
|00006130| 68 28 6f 2e 6d 61 63 68 | 69 6e 65 6c 6f 67 66 64 |h(o.mach|inelogfd|
|00006140| 29 3b 0a 20 69 66 20 28 | 6f 2e 6c 6f 67 66 64 29 |);. if (|o.logfd)|
|00006150| 20 66 66 6c 75 73 68 28 | 6f 2e 6c 6f 67 66 64 29 | fflush(|o.logfd)|
|00006160| 3b 0a 20 20 7d 0a 7d 0a | 0a 69 20 3d 20 74 69 6d |;. }.}.|.i = tim|
|00006170| 65 28 4e 55 4c 4c 29 20 | 2d 20 73 74 61 72 74 74 |e(NULL) |- startt|
|00006180| 69 6d 65 3b 0a 20 66 70 | 72 69 6e 74 66 28 6f 2e |ime;. fp|rintf(o.|
|00006190| 6e 6d 61 70 5f 73 74 64 | 6f 75 74 2c 20 22 4e 6d |nmap_std|out, "Nm|
|000061a0| 61 70 20 72 75 6e 20 63 | 6f 6d 70 6c 65 74 65 64 |ap run c|ompleted|
|000061b0| 20 2d 2d 20 25 64 20 25 | 73 20 28 25 64 20 25 73 | -- %d %|s (%d %s|
|000061c0| 20 75 70 29 20 73 63 61 | 6e 6e 65 64 20 69 6e 20 | up) sca|nned in |
|000061d0| 25 64 20 25 73 5c 6e 22 | 2c 20 6e 75 6d 68 6f 73 |%d %s\n"|, numhos|
|000061e0| 74 73 5f 73 63 61 6e 6e | 65 64 2c 20 28 6e 75 6d |ts_scann|ed, (num|
|000061f0| 68 6f 73 74 73 5f 73 63 | 61 6e 6e 65 64 20 3d 3d |hosts_sc|anned ==|
|00006200| 20 31 29 3f 20 22 49 50 | 20 61 64 64 72 65 73 73 | 1)? "IP| address|
|00006210| 22 20 3a 20 22 49 50 20 | 61 64 64 72 65 73 73 65 |" : "IP |addresse|
|00006220| 73 22 2c 20 6e 75 6d 68 | 6f 73 74 73 5f 75 70 2c |s", numh|osts_up,|
|00006230| 20 28 6e 75 6d 68 6f 73 | 74 73 5f 75 70 20 3d 3d | (numhos|ts_up ==|
|00006240| 20 31 29 3f 20 22 68 6f | 73 74 22 20 3a 20 22 68 | 1)? "ho|st" : "h|
|00006250| 6f 73 74 73 22 2c 20 20 | 69 2c 20 28 69 20 3d 3d |osts", |i, (i ==|
|00006260| 20 31 29 3f 20 22 73 65 | 63 6f 6e 64 22 3a 20 22 | 1)? "se|cond": "|
|00006270| 73 65 63 6f 6e 64 73 22 | 29 3b 0a 72 65 74 75 72 |seconds"|);.retur|
|00006280| 6e 20 30 3b 0a 7d 0a 0a | 76 6f 69 64 20 6f 70 74 |n 0;.}..|void opt|
|00006290| 69 6f 6e 73 5f 69 6e 69 | 74 28 29 20 7b 0a 62 7a |ions_ini|t() {.bz|
|000062a0| 65 72 6f 28 20 28 63 68 | 61 72 20 2a 29 20 26 6f |ero( (ch|ar *) &o|
|000062b0| 2c 20 73 69 7a 65 6f 66 | 28 73 74 72 75 63 74 20 |, sizeof|(struct |
|000062c0| 6f 70 73 29 29 3b 0a 6f | 2e 69 73 72 30 30 74 20 |ops));.o|.isr00t |
|000062d0| 3d 20 21 28 67 65 74 65 | 75 69 64 28 29 29 3b 0a |= !(gete|uid());.|
|000062e0| 6f 2e 64 65 62 75 67 67 | 69 6e 67 20 3d 20 44 45 |o.debugg|ing = DE|
|000062f0| 42 55 47 47 49 4e 47 3b | 0a 6f 2e 76 65 72 62 6f |BUGGING;|.o.verbo|
|00006300| 73 65 20 3d 20 44 45 42 | 55 47 47 49 4e 47 3b 0a |se = DEB|UGGING;.|
|00006310| 2f 2a 6f 2e 6d 61 78 5f | 73 6f 63 6b 65 74 73 20 |/*o.max_|sockets |
|00006320| 3d 20 4d 41 58 5f 53 4f | 43 4b 45 54 53 3b 2a 2f |= MAX_SO|CKETS;*/|
|00006330| 0a 6f 2e 6d 61 67 69 63 | 5f 70 6f 72 74 20 3d 20 |.o.magic|_port = |
|00006340| 33 33 30 30 30 20 2b 20 | 28 67 65 74 5f 72 61 6e |33000 + |(get_ran|
|00006350| 64 6f 6d 5f 75 69 6e 74 | 28 29 20 25 20 33 31 30 |dom_uint|() % 310|
|00006360| 30 30 29 3b 0a 23 69 66 | 64 65 66 20 49 47 4e 4f |00);.#if|def IGNO|
|00006370| 52 45 5f 5a 45 52 4f 5f | 41 4e 44 5f 32 35 35 5f |RE_ZERO_|AND_255_|
|00006380| 48 4f 53 54 53 0a 6f 2e | 61 6c 6c 6f 77 61 6c 6c |HOSTS.o.|allowall|
|00006390| 20 3d 20 21 28 49 47 4e | 4f 52 45 5f 5a 45 52 4f | = !(IGN|ORE_ZERO|
|000063a0| 5f 41 4e 44 5f 32 35 35 | 5f 48 4f 53 54 53 29 3b |_AND_255|_HOSTS);|
|000063b0| 0a 23 65 6e 64 69 66 0a | 6f 2e 70 74 69 6d 65 20 |.#endif.|o.ptime |
|000063c0| 3d 20 50 49 4e 47 5f 54 | 49 4d 45 4f 55 54 3b 0a |= PING_T|IMEOUT;.|
|000063d0| 6f 2e 70 69 6e 67 74 79 | 70 65 20 3d 20 50 49 4e |o.pingty|pe = PIN|
|000063e0| 47 54 59 50 45 5f 55 4e | 4b 4e 4f 57 4e 3b 0a 6f |GTYPE_UN|KNOWN;.o|
|000063f0| 2e 64 65 63 6f 79 74 75 | 72 6e 20 3d 20 2d 31 3b |.decoytu|rn = -1;|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.